@Test public void testSend() { for (int i = 0; i < 50; i++) commandBus.send(new TestCommand("Hello, World")); System.out.println("Warte 10 Sekundne, bis MDB fertig ist"); try { Thread.sleep(10000); } catch (InterruptedException e) { } System.out.println("Test fertgi"); }
@Override public void send(C command) { log.log(Level.FINER, "send command: " + command.getClass()); Session session = null; try { session = createSession(connection); MessageProducer publisher = createProducer(session, commandQueue); Message message = createMessage(session, command); publisher.send(message); } catch (JMSException e) { log.log(Level.SEVERE, "Error sending message: {0}", e.getMessage()); e.printStackTrace(); sessionContext.setRollbackOnly(); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { log.warning("Error '" + e.getErrorCode() + "' closing JMS session: " + e.getMessage()); e.printStackTrace(); } } } }
JMSCommandBus implements CommandBus<C> { @Override public void send(C command) { log.log(Level.FINER, "send command: " + command.getClass()); Session session = null; try { session = createSession(connection); MessageProducer publisher = createProducer(session, commandQueue); Message message = createMessage(session, command); publisher.send(message); } catch (JMSException e) { log.log(Level.SEVERE, "Error sending message: {0}", e.getMessage()); e.printStackTrace(); sessionContext.setRollbackOnly(); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { log.warning("Error '" + e.getErrorCode() + "' closing JMS session: " + e.getMessage()); e.printStackTrace(); } } } } }
JMSCommandBus implements CommandBus<C> { @Override public void send(C command) { log.log(Level.FINER, "send command: " + command.getClass()); Session session = null; try { session = createSession(connection); MessageProducer publisher = createProducer(session, commandQueue); Message message = createMessage(session, command); publisher.send(message); } catch (JMSException e) { log.log(Level.SEVERE, "Error sending message: {0}", e.getMessage()); e.printStackTrace(); sessionContext.setRollbackOnly(); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { log.warning("Error '" + e.getErrorCode() + "' closing JMS session: " + e.getMessage()); e.printStackTrace(); } } } }  }
JMSCommandBus implements CommandBus<C> { @Override public void send(C command) { log.log(Level.FINER, "send command: " + command.getClass()); Session session = null; try { session = createSession(connection); MessageProducer publisher = createProducer(session, commandQueue); Message message = createMessage(session, command); publisher.send(message); } catch (JMSException e) { log.log(Level.SEVERE, "Error sending message: {0}", e.getMessage()); e.printStackTrace(); sessionContext.setRollbackOnly(); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { log.warning("Error '" + e.getErrorCode() + "' closing JMS session: " + e.getMessage()); e.printStackTrace(); } } } }  @PostConstruct void makeConnection(); @Override void send(C command); @PreDestroy void tidyUp(); }
JMSCommandBus implements CommandBus<C> { @Override public void send(C command) { log.log(Level.FINER, "send command: " + command.getClass()); Session session = null; try { session = createSession(connection); MessageProducer publisher = createProducer(session, commandQueue); Message message = createMessage(session, command); publisher.send(message); } catch (JMSException e) { log.log(Level.SEVERE, "Error sending message: {0}", e.getMessage()); e.printStackTrace(); sessionContext.setRollbackOnly(); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { log.warning("Error '" + e.getErrorCode() + "' closing JMS session: " + e.getMessage()); e.printStackTrace(); } } } }  @PostConstruct void makeConnection(); @Override void send(C command); @PreDestroy void tidyUp();  }