/** * Creates a new instance of an AMQP 1.0 protocol handler for Hono's <em>Device Registration</em> API. * * @return The handler. */ @Bean @Scope("prototype") public RegistrationAmqpEndpoint registrationAmqpEndpoint() { return new RegistrationAmqpEndpoint(vertx()); }
@Override public final void processRequest(final Message msg, final ResourceIdentifier targetAddress, final HonoUser clientPrincipal) { final EventBusMessage registrationMsg = EventBusMessage.forOperation(msg) .setReplyToAddress(msg) .setAppCorrelationId(msg) .setCorrelationId(msg) .setTenant(targetAddress.getTenantId()) .setDeviceId(msg) .setGatewayId(msg) .setJsonPayload(msg); final DeliveryOptions options = createEventBusMessageDeliveryOptions(extractSpanContext(msg)); vertx.eventBus().send(RegistrationConstants.EVENT_BUS_ADDRESS_REGISTRATION_IN, registrationMsg.toJson(), options); }
/** * Verifies that the endpoint forwards a request message via the event bus. */ @Test public void testProcessMessageSendsRequestViaEventBus() { final Message msg = ProtonHelper.message(); msg.setMessageId("4711"); msg.setSubject(RegistrationConstants.ACTION_ASSERT); msg.setBody(new AmqpValue(new JsonObject().put("temp", 15).encode())); MessageHelper.annotate(msg, resource); endpoint.processRequest(msg, resource, Constants.PRINCIPAL_ANONYMOUS); verify(eventBus).send(eq(RegistrationConstants.EVENT_BUS_ADDRESS_REGISTRATION_IN), any(JsonObject.class), any(DeliveryOptions.class)); } }
/** * Creates a new instance of an AMQP 1.0 protocol handler for Hono's <em>Device Registration</em> API. * * @return The handler. */ @Bean @Scope("prototype") public RegistrationAmqpEndpoint registrationAmqpEndpoint() { return new RegistrationAmqpEndpoint(vertx()); }
/** * Sets up the fixture. */ @Before public void setUp() { when(vertx.eventBus()).thenReturn(eventBus); endpoint = new RegistrationAmqpEndpoint(vertx); }