How to Listen events in node-red - hyperledger composer - hyperledger

I have deployed my business network using node-red and local composer over fabric. I would like to listen to an event in node-red. I am able to submit the transaction successfully but not able to see the notification emitted by event in the same transaction on debug console in node-red.
composer nodes are latest and Composer is 0.16v. Event url port is 7053. I have attached two images below.
Transaction Submitted - shipmentreceived. When the transaction processor function is executed for this transaction, event is emitted as mentioned below:
var basicEvent=getFactory().newEvent('org.acme.shipping.perishable','ShipmentNotification');
basicEvent.shipmentStatus = shipment.status;
emit(basicEvent);
Model File:
event ShipmentNotification{
o String shipmentStatus
}
Node-red - Submitting and Listening event
This could be error

see https://medium.com/#CazChurchUk/integrate-your-blockchain-with-anything-using-hyperledger-composer-and-nodered-4226676f7e54
it needs to be updated to use 'business network cards' not 'profiles' in the NodeRed node widgets / flow, but the same principle applies where subscribing to events are concerned.

Related

CacheDidUpdate not called after BackgroundSync Sync completed event

This happens on Chrome v. 100 on a MacBook.
I'm using the Workbox's StaleWhileRevalidate together with the BrackgroundSyncPlugin and the BroadcastUpdatePlugin. I have the following scenario:
User opens app offline
App loads cached response
User gets internet connection
BackgroundSyncPlugin retries failed StaleWhileRevalidate request and succeeds
BackgroundSyncPlugin shows Sync completed event in Chrome's dev tools background-sync
Cache is updated
BroadcastUpdatePlugin should broadcast cache is updated
However, I never receive the broadcast. I do receive the broadcast if I refresh the page with internet connection.
Code example:
registerRoute(/^some-working-regex/,new StaleWhileRevalidate(
{
cacheName: 'some-cache-name',
matchOptions: {ignoreVary: true},
plugins: [
new ExpirationPlugin({maxEntries: 20,purgeOnQuotaError: false,}),
new BackgroundSyncPlugin('some-queue-name', {maxRetentionTime: 24 * 60}),
new BroadcastUpdatePlugin()
]}),
"GET"
)
And I do see the sync event after turning on the internet:
Expected outcome:
I expect BroadcastUpdatePlugin to fire when the cache is updated successfully by the BackgroundSyncPlugin after the user obtains connectivity again.
Am I missing a step here?
I've also created a custom plugin with a cacheDidUpdate and the handler also doesn't get called. (so it doesn't seem to be related to the BroadcastUpdatePlugin).
Thanks!

How to send a message from Helix controller to participant?

I want to send a message to all Participant nodes of my Helix cluster from Controller node. I tried following piece of code to send message to all registered participants of my cluster but their registered Participant message listeners are not receiving the message notification from Helix.
Message msg = new Message(factory.getMessageTypes().get(0), msgId);
msg.setMsgId(msgId);
msg.setSrcName(hostSrc);
msg.setTgtSessionId("*");
msg.setMsgState(MessageState.NEW);
msg.getRecord().setSimpleField("TestMessage", "Message from controller");
Criteria recipientCriteria = new Criteria();
recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
recipientCriteria.setInstanceName("%"); // To all recipients
recipientCriteria.setSessionSpecific(true); // To deliver only live participants
recipientCriteria.setSessionSpecific("DEV_CLUSTER"); // To only participants of this cluster
messagingService.send(recipientCriteria,msg);
Note that, when I am sending this message there is no resource exists in the cluster.
After debugging further what I have observed is CriteriaEvaluator.evaluateCriteria(....) operation is returning an empty list which further results into 0 messages to be sent to Participants nodes.
Kindly let me know if I am missing anything here while defining my criteria for Participants.
Thanks !
Update-1: our observation on this issue is as follows:
The received message at the participant side is read by both the Participant message listener(Say L1) and the handler created through MessageHandlerFactory(Which internally creating a listener HelixtaskExecutor (Say L2)).
In case if the message is read by HelixTaskExecutor(L2) first, it then immediately deletes the Znode in Zookeeper and the additionally configured message listener(L1) doesn't receive this message.
In case if the message is first read my additional message listener i.e. L1 then in such scenarios we don't face this problem as this additionally added listener doesn't delete the Znode from ZooKeeper.
We are still not sure how can we handle this problem as we want to use both the listener and MessageHandlers but facing the same problem I stated above.
Any inputs are appreciated.

Photon. OnRoomListUpdate doesn't work after restart WI-FI on Android

PUN2.31 Photon lib: 4.1.6.0
Unity 2019.4.26f1
Hello dear friends!
I have a simple app with rooms. Master creates room, client can join room, client can leave room. If master leaves room client leaves room too. Its ok, its working. (for example Master - UnityEditor, client - AndroidBuild).
When the master creates a room, an callbacks OnRoomListUpdated is triggered for the client correctly.
But if client in lobby and he disconnected from server, then he connected to server, all callbacks is working correctly (OnConnectedToMaster, OnJoinedLobby e.t.c) its ok.
Debug.Log("Client IsConnected = " + PhotonNetwork.IsConnected);
Debug.Log("Client InLobby = " + PhotonNetwork.InLobby);
These logs are true when client reconnected.
But now, if master creates room, client can't join because OnRoomListUpdated callback is not triggering.
Can anyone help or know some reasons of this problem?
Here is a link to video of my problem (at the end of video I restarted WI-FI): https://youtu.be/wkDFxIMfzH8
Master and client had different AppVersion.
Mistake in my code. This part of code I wrote in Awake, but had to write this in callback OnConnectedToMaster
PhotonNetwork.GameVersion = Application.version;

How to let Lettuce notify application when connection is down?

We are using Lettuce in our project. We have a requirement to monitor the status of connection.
I know Lettuce can re-connect Redis when the connection is down. But is there some way to notify application that the connection is down/up?
Thanks,
Steven
Lettuce provides an event-model for connection events. You can subscribe to the EventBus and react to events published on the bus. There are multiple events, but for your case, you'd want to listen to connected and disconnected events:
ConnectionActivatedEvent: The logical connection is activated and can be used to dispatch Redis commands (SSL handshake complete, PING before activating response received)
ConnectionDeactivatedEvent: The logical connection is deactivated. The internal processing state is reset and the isOpen() flag is set to false.
Both events are fired after receiving Transport-related events such as ConnectedEvent respective DisconnectedEvent.
The following example illustrates how to consume these events:
RedisClient client = RedisClient.create()
EventBus eventBus = client.getresources().eventBus();
Disposable subscription = eventBus.get().subscribe(e -> {
if (e instanceOf ConnectionActivatedEvent) {
// …
}
});
…
subscription.dispose();
client.shutdown();
Please note that events are dispatched asynchronously. Anything that happens in the event listener should be non-blocking (i.e. if you need to call blocking code such as further Redis interaction, please offload this task to a dedicated Thread).
Read more
Lettuce Reference Documentation: Events

Cooja - How to assign different services to a mote/node?

I need to create a network of 10 motes. I want each mote to provide 3 services with s1 = 0.25, s2 = 0.5 and s3 = 0.025. Also, I want to identify / select selfish / malicious mote(s).
Any help will be highly appreciated.
A solution to this should not be complicated to write yourself but I guess you can look at using the service registration and dissemination hack (servreg-hack) application in contiki. The operation of the application is very simple, all the application does is enable nodes to advertise services that they offer by broadcasting a SERVICE_ID (which is just an unsigned 8-bit integer). When a another node in the vicinity of the broadcasting node receives a message it stores the SERVICE_ID and the address of the node that sent the message. If the node needs a service, it can then just look up the address of a node that offers the service by calling the servreg_hack_lookup function.
The unicast-sender and unicast receiver applications in the examples section of the contiki distribution (Contiki/examples/ipv6/simple-udp-rpl) use servreg_hack.
So on both nodes you would initialise the servreg app by calling
servreg_hack_init();
then on the service provider you would register a service by calling
servreg_hack_register(SERVICE_ID, service_provider_ip_addr);
this service would then be received and registered on the service user node. The service user would can then call
service_provider_ipaddr = servreg_hack_lookup(SERVICE_ID);
to get the address of the node that provides the service identified by SERVICE_ID.

Resources