/** * Extracts and returns the topic QName contained by the specified * {@link NotificationMessageHolderType WS-Notification message}. * * @param notificationMessage * the WS-Notification message to analyze. * * @return the topic QName contained by the specified WS-Notification * message. */ public static QName getTopic(NotificationMessageHolderType notificationMessage) { return getTopic(notificationMessage.getTopic()); }
/** * Indicates whether the topic of the specified * {@link NotificationMessageHolderType WS-Notification message} is defined * by a {@code simpleTopicExpression} element or not. * * @param notificationMessage * the WS-Notification message to analyze. * * @return true if the topic of the specified WS-Notification message is * defined by a {@code simpleTopicExpression} element, false * otherwise. */ public static boolean hasSimpleTopicExpression(NotificationMessageHolderType notificationMessage) { return hasSimpleTopicExpression(notificationMessage.getTopic()); }
private static List<SubscriptionInfo> GetMatchingSubscribers(List<NotificationMessageHolderType> notificationMessage) { ArrayList<SubscriptionInfo> list = new ArrayList<SubscriptionInfo>(); if (notificationMessage.isEmpty()) { return list; } Map subs = new HashMap(currentSubscriptions); Iterator it = subs.keySet().iterator(); while (it.hasNext()) { //for each subscription SubscriptionInfo si = (SubscriptionInfo) subs.get(it.next()); //if one of the inbound notify's topic matching a subscription's topic, add to the list for (int i = 0; i < notificationMessage.size(); i++) { if (SubscriptionContains(si, notificationMessage.get(i).getTopic())) { list.add(si); } } } return list; }
static String GetTopicList(Notify n) { String s = new String(); if (n == null) { return s; } for (int i = 0; i < n.getNotificationMessage().size(); i++) { if (n.getNotificationMessage().get(i).getTopic() != null) { if (n.getNotificationMessage().get(i).getTopic().getContent() != null) { for (int k = 0; k < n.getNotificationMessage().get(i).getTopic().getContent().size(); k++) { s = s + " " + n.getNotificationMessage().get(i).getTopic().getContent().get(k).toString(); } } } } return s.trim(); }
@Override public void notify(NotificationMessageHolderType messageHolder) { Session session = null; try { Topic topic = topicConverter.toActiveMQTopic(messageHolder.getTopic()); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(topic); Notify notify = new Notify(); notify.getNotificationMessage().add(messageHolder); StringWriter writer = new StringWriter(); jaxbContext.createMarshaller().marshal(notify, writer); Message message = session.createTextMessage(writer.toString()); producer.send(message); } catch (JMSException | JAXBException | InvalidTopicException e) { LOGGER.log(Level.WARNING, "Error dispatching message", e); } finally { if (session != null) { try { session.close(); } catch (JMSException e) { LOGGER.log(Level.FINE, "Error closing session", e); } } } }
msg.getSubscriptionReference(), "subscriber"); logTopic(msg.getTopic(), "");
Map<Node, Node> messageNodes = new HashMap<Node, Node>(); if (notificationMessage.getTopic() != null) { QName topic = WsnHelper.getTopic(notificationMessage); String topicNamespace = topic.getNamespaceURI();