/** * Create a consumer for the jms destination * * @throws Exception */ protected void createConsumer() throws Exception { try { JmsSupport jmsSupport = this.connector.getJmsSupport(); // Create session if none exists if (session == null) { session = this.connector.getSession(endpoint); } boolean topic = connector.getTopicResolver().isTopic(endpoint, true); // Create destination Destination dest = jmsSupport.createDestination(session, endpoint.getEndpointURI().getAddress(), topic); // Extract jms selector String selector = null; if (endpoint.getFilter() != null && endpoint.getFilter() instanceof JmsSelectorFilter) { selector = ((JmsSelectorFilter) endpoint.getFilter()).getExpression(); } else if (endpoint.getProperties() != null) { // still allow the selector to be set as a property on the endpoint // to be backward compatable selector = (String) endpoint.getProperties().get(JmsConstants.JMS_SELECTOR_PROPERTY); } String tempDurable = (String) endpoint.getProperties().get(JmsConstants.DURABLE_PROPERTY); boolean durable = connector.isDurable(); if (tempDurable != null) { durable = Boolean.valueOf(tempDurable).booleanValue(); } // Get the durable subscriber name if there is one String durableName = (String) endpoint.getProperties().get(JmsConstants.DURABLE_NAME_PROPERTY); if (durableName == null && durable && dest instanceof Topic) { durableName = "mule." + connector.getName() + "." + endpoint.getEndpointURI().getAddress(); logger.debug( "Jms Connector for this receiver is durable but no durable name has been specified. Defaulting to: " + durableName); } // Create consumer consumer = jmsSupport.createConsumer( session, dest, selector, connector.isNoLocal(), durableName, topic); } catch (JMSException e) { throw new ConnectException(e, this); } }
protected MessageConsumer createReplyToConsumer( Message currentMessage, MuleEvent event, Session session, Destination replyTo, boolean topic) throws JMSException { String selector = null; // Only used by topics String durableName = null; // If we're not using if (!(replyTo instanceof TemporaryQueue || replyTo instanceof TemporaryTopic)) { String jmsCorrelationId = currentMessage.getJMSCorrelationID(); if (jmsCorrelationId == null) { jmsCorrelationId = currentMessage.getJMSMessageID(); } selector = "JMSCorrelationID='" + jmsCorrelationId + "'"; if (logger.isDebugEnabled()) { logger.debug("ReplyTo Selector is: " + selector); } } // We need to set the durableName and Selector if using topics if (topic) { String tempDurable = (String) event.getEndpoint().getProperties().get(JmsConstants.DURABLE_PROPERTY); boolean durable = connector.isDurable(); if (tempDurable != null) { durable = Boolean.valueOf(tempDurable); } // Get the durable subscriber name if there is one durableName = (String) event.getEndpoint().getProperties().get(JmsConstants.DURABLE_NAME_PROPERTY); if (durableName == null && durable && topic) { durableName = "mule." + connector.getName() + "." + event.getEndpoint().getEndpointURI().getAddress(); if (logger.isDebugEnabled()) { logger.debug( "Jms Connector for this receiver is durable but no durable name has been specified. Defaulting to: " + durableName); } } } return connector .getJmsSupport() .createConsumer(session, replyTo, selector, connector.isNoLocal(), null, topic, endpoint); }