@Test void testError() throws IOException { when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent)); when(mockEvent.getCreated()).thenReturn(time); when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:amqp:test")); when(mockEvent.getTypes()).thenReturn(singleton(AS.Update)); when(mockEvent.getObject()).thenReturn(of(rdf.createIRI(TRELLIS_DATA_PREFIX + "resource"))); when(mockEvent.getObjectTypes()).thenReturn(singleton(LDP.RDFSource)); when(mockEvent.getInbox()).thenReturn(empty()); doThrow(IOException.class).when(mockChannel).basicPublish(eq(exchangeName), eq(queueName), anyBoolean(), anyBoolean(), any(BasicProperties.class), any(byte[].class)); final EventService svc = new AmqpEventService(serializer, mockChannel, exchangeName, queueName, true, true); svc.emit(mockEvent); verify(mockChannel).basicPublish(eq(exchangeName), eq(queueName), anyBoolean(), anyBoolean(), any(BasicProperties.class), any(byte[].class)); }
@Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); final BasicProperties props = new BasicProperties().builder() .contentType("application/ld+json").contentEncoding("UTF-8").build(); try { channel.basicPublish(exchangeName, routingKey, mandatory, immediate, props, service.serialize(event).getBytes(UTF_8)); } catch (final IOException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } }
AmqpEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); final BasicProperties props = new BasicProperties().builder() .contentType("application/ld+json").contentEncoding("UTF-8").build(); try { channel.basicPublish(exchangeName, routingKey, mandatory, immediate, props, service.serialize(event).getBytes(UTF_8)); } catch (final IOException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } }
AmqpEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); final BasicProperties props = new BasicProperties().builder() .contentType("application/ld+json").contentEncoding("UTF-8").build(); try { channel.basicPublish(exchangeName, routingKey, mandatory, immediate, props, service.serialize(event).getBytes(UTF_8)); } catch (final IOException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } AmqpEventService(); @Inject  AmqpEventService(final EventSerializationService serializer, final Channel channel); private  AmqpEventService(final EventSerializationService serializer, final Channel channel, final Config config);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey, final boolean mandatory, final boolean immediate); }
AmqpEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); final BasicProperties props = new BasicProperties().builder() .contentType("application/ld+json").contentEncoding("UTF-8").build(); try { channel.basicPublish(exchangeName, routingKey, mandatory, immediate, props, service.serialize(event).getBytes(UTF_8)); } catch (final IOException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } AmqpEventService(); @Inject  AmqpEventService(final EventSerializationService serializer, final Channel channel); private  AmqpEventService(final EventSerializationService serializer, final Channel channel, final Config config);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey, final boolean mandatory, final boolean immediate); @Override void emit(final Event event); }
AmqpEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); final BasicProperties props = new BasicProperties().builder() .contentType("application/ld+json").contentEncoding("UTF-8").build(); try { channel.basicPublish(exchangeName, routingKey, mandatory, immediate, props, service.serialize(event).getBytes(UTF_8)); } catch (final IOException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } AmqpEventService(); @Inject  AmqpEventService(final EventSerializationService serializer, final Channel channel); private  AmqpEventService(final EventSerializationService serializer, final Channel channel, final Config config);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey);  AmqpEventService(final EventSerializationService serializer, final Channel channel,
            final String exchangeName, final String routingKey, final boolean mandatory, final boolean immediate); @Override void emit(final Event event); static final String CONFIG_AMQP_EXCHANGE_NAME; static final String CONFIG_AMQP_ROUTING_KEY; static final String CONFIG_AMQP_MANDATORY; static final String CONFIG_AMQP_IMMEDIATE; static final String CONFIG_AMQP_URI; }