public void presumePublishTopic(Writable writable, WaitFor waitFor) { assert((0 != (msgCommandChannel.initFeatures & MsgCommandChannel.DYNAMIC_MESSAGING))) : "CommandChannel must be created with DYNAMIC_MESSAGING flag"; if (!publishTopic(writable, waitFor)) { logger.warn("unable to publish on topic {} must wait.",topic); while (!publishTopic(writable, waitFor)) { Thread.yield(); } } }
@Override public boolean restRequest(HTTPRequestReader request) { return cmd.publishTopic((writer)->{ request.handoff(writer); }); }
@Override public boolean restRequest(HTTPRequestReader request) { return cmd.publishTopic((writer)->{ request.handoff(writer); }); }
@Override public void startup() { target.append("Your lucky numbers are ...\n"); channel0.publishTopic(); }
public boolean triggerNextAndCount(CharSequence topic, ChannelReader payload) { if(count<6) { boolean result = channel.publishTopic(); if (result) { count++; } return result; } else { if (doShutdown) { runtime.shutdownRuntime(); } } return true; }
@Override public void timeEvent(long time, int iteration) { int i = 1;//iterations while (--i>=0) { Date d = new Date(System.currentTimeMillis()); // On the timer event create a payload with a string encoded timestamp Writable writable = writer -> writer.writeUTF8Text("'MQTT egress body " + d + "'"); // Send out the payload with thre MQTT topic "topic/egress" boolean ok = cmdChnl.publishTopic(writable, WaitFor.None); if (ok) { System.err.println("sent "+d+" total "+(++total)); } else { droppedCount++; System.err.println("The system is backed up, dropped "+droppedCount); } } } }
@Override public boolean message(CharSequence topic, ChannelReader payload) { //Note if this behavior is subscribed to more than 1 topic we will need //to branch here based on the value of topic. Appendables.appendValue(target, rand.nextInt(101)).append(' '); return channel.publishTopic(); }
public boolean receiveMqttMessage(CharSequence topic, ChannelReader payload) { // this received when mosquitto_pub is invoked - see MQTTClient System.out.print("\ningress body: "); // Read the message payload and output it to System.out payload.readUTFOfLength(payload.available(), System.out); System.out.println(); // Create the on-demand mqtt payload writer Writable mqttPayload = writer -> writer.writeUTF("\nsecond step test message"); // On the 'localtest' topic publish the mqtt payload cmd.publishTopic(mqttPayload, WaitFor.None); // We consumed the message return true; } }
public boolean productAll(HTTPRequestReader request) { return publishService.publishTopic((w)->{ StructuredWriter target = w.structured(); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_ALL_QUERY); }); }
public boolean productQuery(HTTPRequestReader request) { StructuredReader source = request.structured(); return publishService.publishTopic((w)->{ StructuredWriter target = w.structured(); target.writeInt(Field.ID, source.readInt(Field.ID)); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_PRODUCT_QUERY); }); }
peekInputStream.absolutePosition(absPos); boolean ok = targetService[idx].publishTopic(w -> { peekInputStream.readInto(w,peekInputStream.available());
public boolean productUpdate(HTTPRequestReader request) { StructuredReader source = request.structured(); return publishService.publishTopic((w)->{ //write update message with new payload plus sequence and connectionID StructuredWriter target = w.structured(); target.writeInt(Field.ID, source.readInt(Field.ID)); target.writeInt(Field.QUANTITY, source.readInt(Field.QUANTITY)); target.writeBoolean(Field.DISABLED, source.readBoolean(Field.DISABLED)); //source.readText(Field.NAME, target.writeText(Field.NAME)); //Broken?? target.writeText(Field.NAME, source.readText(Field.NAME)); target.writeLong(Field.CONNECTION, request.getConnectionId()); target.writeLong(Field.SEQUENCE, request.getSequenceCode()); target.selectStruct(Struct.DB_PRODUCT_UPDATE); }); }
pubSubService[topicIdx].publishTopic(w->{ convertersSub[topicIdx].convertData(payload, w); }); conFeedbackService.publishTopic((w)-> { w.writeInt(MQTTConnectionStatus.fromSpecification(resultCode).getSpecification()); w.writeBoolean(sessionPresent != 0);