Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 6a14e82

Browse files
authored
Issues #313/763/803/882/673 (#1024)
* Updates for work * Adding Installing Index to ToC * Removing Fabric Composer name * Removing Fabric composer name * Moving images for REST API doc * Fabric Composer Name removal * Fabric Composer name removal * Other name changes (Stack Overflow, GitHub, Rocket.Chat, JavaScript) * wording updates and bug splats * ToC Updates * HLv1 docs updates, couple more bug splats. * Last edit for HLv1 * Whoops, bug splat * Another bug splat... * Quick fixes prereqs navbar * intro diagram fix and bug fixes * Fixes and updates * Rollback optional script for v1.0 * QoL changes and rollback changes - Quickstart * Link fixes * Atom links fix, formatting fix * Odd formatting fix. * Name change and codeblock fix * More odd formatting fixes * Ubuntu root user doc fix + draft of bnd doc changes * update for CLI define + deploy BNA * last bnd update * Events and bug fixes * Last event thing * Updates for #803 and #822 * removing unnecessary stuff * Undeploy support #673 * Clarifications on undeploy
1 parent fa2c481 commit 6a14e82

File tree

12 files changed

+288
-268
lines changed

12 files changed

+288
-268
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
layout: default
3+
title: Subscribing to events
4+
category: tasks
5+
sidebar: sidebars/applications.md
6+
excerpt: Subscribing to events
7+
---
8+
9+
# Subscribing to events
10+
11+
Applications can subscribe to events from a business network by using the `composer-client.BusinessNetworkConnection.on` API call. Events are defined in the business network model file and are emitted by specified transactions in the transaction processor function file. For more information on publishing events, see [publishing events](../business-network/publishing-events.html).
12+
13+
## Before you begin
14+
15+
Before an application can subscribe to events, you must have defined some events and the transactions which will emit them. The business network must also be deployed and you must have connected to it. Follow the steps for [connecting to the {{site.data.conrefs.composer_full}} runtime](../applications/getting-started-nodejs-app.html).
16+
17+
## Procedure
18+
19+
1. An application must send a specific API call to subscribe to events emitted transactions in a business network. Currently, an application which subscribes to events will receive all events which are emitted. The API call should take the following format:
20+
21+
```Javascript
22+
businessNetworkConnection.on('event', (event) => {
23+
// event: { "$class": "org.namespace.BasicEvent", "eventId": "0000-0000-0000-000000#0" }
24+
console.log(event);
25+
});
26+
```
27+
28+
This includes an event called `BasicEvent` which was created in the [publishing events](../business-network/publishing-events.html) documentation. The `eventId` property is always the same as the `transactionId` of the transaction which emitted the event, with an appended number in the form `"transactionId": "<transactionId>#number"`.
29+
30+
## What next?
31+
32+
The application will now receive all of the events emitted by the business network, and it's up to the application to choose to what extent those events are integrated.
33+
34+
---
Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: default
3-
title: Task - Deploy a Business Network
3+
title: Task - Deploy a Business Network Definition
44
category: tasks
55
sidebar: sidebars/businessnetworks.md
66
excerpt: How to deploy a Business Network
@@ -10,45 +10,42 @@ excerpt: How to deploy a Business Network
1010

1111
---
1212

13-
A business network is deployed using the `composer network deploy` command.
13+
A business network definition is deployed using the `composer network deploy` command.
1414

15-
## Procedure
16-
17-
1. Before deploying a business network, a [Business Network Definition](../business-network/businessnetworkdefinition.html) is needed as a `zip` file with the following structure:
15+
# Before you begin
1816

19-
```
20-
BusinessNetworkArchive.zip
21-
├── lib
22-
│   └── mozart.cto.js
23-
├── models
24-
│   └── mozart.cto
25-
└── package.json
26-
```
17+
Before deploying a business network, a [Business Network Definition](../business-network/businessnetworkdefinition.html) is needed as a `zip` file with the following structure:
2718

28-
-_lib_ contains all of the transactions processor functions
29-
-_models_ contains all of the model files written in the [CTO Language](../reference/cto_language.html).
30-
-_package.json_ is required, and is used to create the [Business Network Definition](../business-network/businessnetworkdefinition.html)'s identifier
19+
```
20+
BusinessNetworkArchive.zip
21+
├── lib
22+
│   └── mozart.cto.js
23+
├── models
24+
│   └── mozart.cto
25+
└── package.json
26+
```
27+
<!--
28+
You can use the `composer archive` command to create an archive with the correct format.
3129
32-
You can use the `composer archive` command to create an archive with the correct format.
30+
**NOTE**: *Do not zip a a folder containing **lib**, **models**, and **package.json** to create an Business Network Archive, zip the contents themselves*
31+
-->
3332

34-
**NOTE**: *Do not zip a a folder containing **lib**, **models**, and **package.json** to create an Business Network Archive, zip the contents themselves*
35-
36-
2. Start [Hyperledger Fabric Peer and Membership Service](runtime-start.md)
33+
## Procedure
3734

38-
3. [Create a Connection Profile](../installing/createconnectionprofile.html) or do *not* use `-p` and allow {{site.data.conrefs.composer_full}} to create a `Default Connection Profile` for you.
35+
1. Start [Hyperledger Fabric Peer and Membership Service](runtime-start.md).
3936

40-
4. Enter the command on a single line. For example:
37+
2. [Create a Connection Profile](../installing/createconnectionprofile.html) or do *not* use `-p` and allow {{site.data.conrefs.composer_full}} to create a `Default Connection Profile` for you.
4138

42-
`composer network deploy -a <BusinessNetworkDefinition>.zip -i <Your EnrollmentID>`
39+
3. Enter the command on a single line. For example:
4340

44-
5. Enter your Enrollment Secret when prompted.
41+
`composer network deploy -a <BusinessNetworkDefinition>.zip -i <Your EnrollmentID>`
4542

46-
`prompt: What is the enrollment secret of the user?:`
43+
4. Enter your Enrollment Secret when prompted.
4744

48-
6. When you see
45+
5. When you see
4946

50-
```
51-
Deploying business network definition. This may take a little time.
52-
Command completed successfully.
53-
```
54-
you have successfully deployed a business network!
47+
```
48+
Deploying business network definition. This may take a little time.
49+
Command completed successfully.
50+
```
51+
the business network definition has been successfully deployed.

0 commit comments

Comments
 (0)