public void onMessage(Message jmsMessage) { try { TextMessage text = (TextMessage) jmsMessage; XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(text.getText())); Notify notify = (Notify) jaxbContext.createUnmarshaller() .unmarshal(reader); reader.close(); for (Iterator<NotificationMessageHolderType> ith = notify.getNotificationMessage().iterator(); ith.hasNext();) { NotificationMessageHolderType h = ith.next(); Object content = h.getMessage().getAny(); if (!(content instanceof Element)) { DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment(); jaxbContext.createMarshaller().marshal(content, doc); content = DOMUtils.getFirstElement(doc); } if (!doFilter((Element) content)) { ith.remove(); } else { h.setTopic(topic); h.setSubscriptionReference(getEpr()); } } if (!notify.getNotificationMessage().isEmpty()) { doNotify(notify); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Error notifying consumer", e); } }
public void notify(Referencable publisher, String topic, Object msg) { getBroker(); if (this.context != null) { try { DOMResult result = new DOMResult(); context.createMarshaller().marshal(msg, result); msg = result.getNode(); if (msg instanceof Document) { msg = ((Document)msg).getDocumentElement(); } } catch (JAXBException e) { //ignore, we'll try and let the runtime handle it as is } } Notify notify = new Notify(); NotificationMessageHolderType holder = new NotificationMessageHolderType(); if (publisher != null) { holder.setProducerReference(publisher.getEpr()); } if (topic != null) { TopicExpressionType topicExp = new TopicExpressionType(); topicExp.getContent().add(topic); holder.setTopic(topicExp); } holder.setMessage(new NotificationMessageHolderType.Message()); holder.getMessage().setAny(msg); notify.getNotificationMessage().add(holder); getBroker().notify(notify); }
topicExpression.getContent().add(topic); notificationMessage.setTopic(topicExpression);
notificationMessage.setTopic(createTopicExpressionTypeWithSimpleExpressionType(topic));
RegisterProducer((String) tet.getContent().get(0)); msg.setTopic((tet)); Message m = new Message();