@Test void testTopic() throws JMSException { when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent)); when(mockEvent.getCreated()).thenReturn(time); when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:jms:test")); when(mockEvent.getTypes()).thenReturn(singleton(AS.Update)); when(mockEvent.getObject()).thenReturn(of(rdf.createIRI(TRELLIS_DATA_PREFIX + "a-resource"))); when(mockEvent.getObjectTypes()).thenReturn(singleton(LDP.RDFSource)); when(mockEvent.getInbox()).thenReturn(empty()); when(mockSession.createTopic(eq(queueName))).thenReturn(mockTopic); when(mockSession.createTextMessage(anyString())).thenReturn(mockMessage); when(mockSession.createProducer(any(Topic.class))).thenReturn(mockTopicProducer); final EventService svc = new JmsEventService(serializer, mockSession, queueName, false); svc.emit(mockEvent); verify(mockTopicProducer).send(eq(mockMessage)); verify(mockProducer, never()).send(eq(mockMessage)); }
@Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); try { final Message message = session.createTextMessage(serializer.serialize(event)); message.setStringProperty("Content-Type", "application/ld+json"); producer.send(message); } catch (final JMSException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } }
JmsEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); try { final Message message = session.createTextMessage(serializer.serialize(event)); message.setStringProperty("Content-Type", "application/ld+json"); producer.send(message); } catch (final JMSException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } }
JmsEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); try { final Message message = session.createTextMessage(serializer.serialize(event)); message.setStringProperty("Content-Type", "application/ld+json"); producer.send(message); } catch (final JMSException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } JmsEventService(); @Inject  JmsEventService(final EventSerializationService serializer, final Connection conn);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName,
            final boolean useQueue); }
JmsEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); try { final Message message = session.createTextMessage(serializer.serialize(event)); message.setStringProperty("Content-Type", "application/ld+json"); producer.send(message); } catch (final JMSException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } JmsEventService(); @Inject  JmsEventService(final EventSerializationService serializer, final Connection conn);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName,
            final boolean useQueue); @Override void emit(final Event event); }
JmsEventService implements EventService { @Override public void emit(final Event event) { requireNonNull(event, "Cannot emit a null event!"); try { final Message message = session.createTextMessage(serializer.serialize(event)); message.setStringProperty("Content-Type", "application/ld+json"); producer.send(message); } catch (final JMSException ex) { LOGGER.error("Error writing to broker: {}", ex.getMessage()); } } JmsEventService(); @Inject  JmsEventService(final EventSerializationService serializer, final Connection conn);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName);  JmsEventService(final EventSerializationService serializer, final Session session, final String queueName,
            final boolean useQueue); @Override void emit(final Event event); static final String CONFIG_JMS_QUEUE_NAME; static final String CONFIG_JMS_URL; static final String CONFIG_JMS_USERNAME; static final String CONFIG_JMS_PASSWORD; static final String CONFIG_JMS_USE_QUEUE; }