@Override public int doStartTag() throws JspException { String context = ""; try { System.out.println("jsp tag start..."); ut.begin(); JMSProducer producer = jmsContext.createProducer(); TextMessage msg = jmsContext.createTextMessage("Hello JSP Tag"); producer.send(queue, msg); context = jmsContext.toString(); ut.commit(); if (context.indexOf(transactionScope) == -1) { throw new JspException("NOT in transaction scope!"); } // Get the writer object for output. JspWriter out = pageContext.getOut(); // Perform substr operation on string. out.println(text); } catch (Exception e) { throw new JspException(e); } return SKIP_BODY; }
@Override public void onMessage(Message message) { JMSProducer producer = context.createProducer(); try { // What we need to do is find classification entries that have not been // filled out. When we find them, we send a message to *another* queue, // saying "run this classification" - with an expiry of 45 seconds. List<Classification> classifications = classificationService.findUnclassifiedEntries(); for (Classification classification : classifications) { ObjectMessage classificationMessage = context.createObjectMessage(classification); classificationMessage.setJMSExpiration(45 * 1000); producer.send(classificationQueue, classificationMessage); } } catch (JMSException jmsException) { jmsException.printStackTrace(); } }