@Override public void start() throws Exception { AmqpBridge bridge = AmqpBridge.create(vertx); // Start the bridge, then use the event loop thread to process things thereafter. bridge.start("localhost", 5672, res -> { if(!res.succeeded()) { System.out.println("Bridge startup failed: " + res.cause()); return; } // Set up a producer using the bridge, send a message with it. MessageProducer<JsonObject> producer = bridge.createProducer("myAmqpAddress"); // Schedule sending of a message every second System.out.println("Producer created, scheduling sends."); vertx.setPeriodic(1000, v -> { JsonObject amqpMsgPayload = new JsonObject(); amqpMsgPayload.put(AmqpConstants.BODY, "myStringContent" + count); producer.send(amqpMsgPayload); System.out.println("Sent message: " + count++); }); }); }
/** * Creates a producer to the given AMQP address. * * This method MUST be called from the bridge Context thread, as used in the result handler callback from the start * methods. The bridge MUST be successfully started before the method is called. * @param amqpAddress the address to produce to * @return the producer */ public <T> io.vertx.rxjava.core.eventbus.MessageProducer<T> createProducer(String amqpAddress) { io.vertx.rxjava.core.eventbus.MessageProducer<T> ret = io.vertx.rxjava.core.eventbus.MessageProducer.newInstance(delegate.createProducer(amqpAddress), io.vertx.lang.rx.TypeArg.unknown()); return ret; }
bridge2.start("localhost", PORT, res -> { if (res.succeeded()) { MessageProducer<JsonObject> producer = bridge2.createProducer(ADDRESS); vertx.setPeriodic(1000, id -> { producer.send(new JsonObject().put("body", "the-content"));
MessageProducer<JsonObject> producer = bridge.createProducer(testName);
context.assertTrue(startResult.succeeded()); MessageProducer<JsonObject> producer = bridge.createProducer(destinationName);
context.assertTrue(startResult.succeeded()); MessageProducer<JsonObject> producer = bridge.createProducer(destinationName);
context.assertTrue(startResult.succeeded()); MessageProducer<JsonObject> producer = bridge.createProducer(destinationName);
MessageProducer<JsonObject> producer = bridge.createProducer(testName); producer.exceptionHandler(x -> { exceptionHandlerCalled.set(true);
context.assertTrue(res.succeeded()); MessageProducer<JsonObject> producer = bridge.createProducer(testName);
context.assertTrue(res.succeeded()); MessageProducer<JsonObject> producer = bridge.createProducer(testName);