/** {@inheritDoc} */ @Override public void mapTo(Context context, JMSBindingData target) throws Exception { super.mapTo(context, target); Message message = target.getMessage(); for (Property property : context.getProperties()) { String name = property.getName(); if (matches(name)) { Object value = property.getValue(); if (value == null) { continue; } try { // process JMS headers if (name.equals(HEADER_JMS_DESTINATION)) { message.setJMSDestination(Destination.class.cast(value)); } else if (name.equals(HEADER_JMS_DELIVERY_MODE)) { message.setJMSDeliveryMode(Integer.parseInt(value.toString())); } else if (name.equals(HEADER_JMS_EXPIRATION)) { message.setJMSExpiration(Long.parseLong(value.toString())); } else if (name.equals(HEADER_JMS_PRIORITY)) { message.setJMSPriority(Integer.parseInt(value.toString())); } else if (name.equals(HEADER_JMS_MESSAGE_ID)) { message.setJMSMessageID(value.toString()); } else if (name.equals(HEADER_JMS_TIMESTAMP)) { message.setJMSTimestamp(Long.parseLong(value.toString())); } else if (name.equals(HEADER_JMS_CORRELATION_ID)) { message.setJMSCorrelationID(value.toString()); } else if (name.equals(HEADER_JMS_REPLY_TO)) { message.setJMSReplyTo(Destination.class.cast(value)); } else if (name.equals(HEADER_JMS_TYPE)) { message.setJMSType(value.toString()); } else if (name.equals(HEADER_JMS_REDELIVERED)) { message.setJMSRedelivered(Boolean.parseBoolean(value.toString())); // process JMS properties } else { message.setObjectProperty(name, value); } } catch (Throwable t) { continue; } } else if (matches(name, getIncludeRegexes(), new ArrayList<Pattern>())) { Object value = property.getValue(); if (value == null) { continue; } message.setObjectProperty(name, value); } } }
/** {@inheritDoc} */ @Override public void mapTo(Context context, JMSBindingData target) throws Exception { Message message = target.getMessage(); for (Property property : context.getProperties(Scope.EXCHANGE)) { String name = property.getName(); if (matches(name)) { Object value = property.getValue(); if (value != null) { try { // Context EXCHANGE properties -> JMS Message properties message.setObjectProperty(name, value); } catch (Throwable t) { // ignore and keep going (here just to keep checkstyle happy) t.getMessage(); } } } } }
/** {@inheritDoc} */ @Override public void mapFrom(JMSBindingData source, Context context) throws Exception { Message message = source.getMessage(); Enumeration<?> e = message.getPropertyNames(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); if (matches(key)) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { // JMS Message properties -> Context EXCHANGE properties context .setProperty(key, value, Scope.EXCHANGE) .addLabels(JCAComposition.JCA_MESSAGE_PROPERTY); } } } }
/** {@inheritDoc} */ @Override public void mapFrom(JMSBindingData source, Context context) throws Exception { super.mapFrom(source, context); Message message = source.getMessage(); // process JMS headers if (matches(HEADER_JMS_DESTINATION)) { context .setProperty(HEADER_JMS_DESTINATION, message.getJMSDestination()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_DELIVERY_MODE)) { context .setProperty(HEADER_JMS_DELIVERY_MODE, message.getJMSDeliveryMode()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_EXPIRATION)) { context .setProperty(HEADER_JMS_EXPIRATION, message.getJMSExpiration()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_PRIORITY)) { context .setProperty(HEADER_JMS_PRIORITY, message.getJMSPriority()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_MESSAGE_ID)) { context .setProperty(HEADER_JMS_MESSAGE_ID, message.getJMSMessageID()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_TIMESTAMP)) { context .setProperty(HEADER_JMS_TIMESTAMP, message.getJMSTimestamp()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_CORRELATION_ID)) { context .setProperty(HEADER_JMS_CORRELATION_ID, message.getJMSCorrelationID()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_REPLY_TO)) { context .setProperty(HEADER_JMS_REPLY_TO, message.getJMSReplyTo()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_TYPE)) { context.setProperty(HEADER_JMS_TYPE, message.getJMSType()).addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_REDELIVERED)) { context .setProperty(HEADER_JMS_REDELIVERED, message.getJMSRedelivered()) .addLabels(JMS_HEADER_LABELS); } // process JMS properties Enumeration<?> e = message.getPropertyNames(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); if (matches(key)) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { context.setProperty(key, value).addLabels(JMS_PROPERTY_LABELS); } } else if (matches(key, getIncludeRegexes(), new ArrayList<Pattern>())) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { context.setProperty(key, value).addLabels(JMS_PROPERTY_LABELS); } } } }