/** * Build a consumer for the default channel type and destination * @param destination destination name * @param topic subtopic * @return consumer */ public synchronized Consumer getConsumer(String destination, String topic) { return getConsumer(destination, topic, channelFactory.getDefaultChannelType()); }
/** * Build a producer for the default channel type and destination * @param destination destination name * @param topic subtopic * @return producer */ public synchronized Producer getProducer(String destination, String topic) { return getProducer(destination, topic, channelFactory.getDefaultChannelType()); }
/** * Build a producer for the specified channel type and destination * @param destination destination name * @param topic subtopic * @param channelType channel type * @return producer */ public synchronized Producer getProducer(String destination, String topic, String channelType) { if (channelType == null) channelType = channelFactory.getDefaultChannelType(); MessagingChannel messagingChannel = getMessagingChannel(channelType); if (messagingChannel == null) throw new IllegalStateException("Channel not defined for server session"); String key = "P:" + destination + '@' + topic; Producer producer = (Producer)topicAgents.get(key); if (producer == null) { producer = serviceFactory.newProducer(messagingChannel, destination, topic); topicAgents.put(key, producer); } return producer; }
/** * Build a consumer for the specified channel type and destination * @param destination destination name * @param topic subtopic * @param channelType channel type * @return consumer */ public synchronized Consumer getConsumer(String destination, String topic, String channelType) { if (channelType == null) channelType = channelFactory.getDefaultChannelType(); MessagingChannel messagingChannel = getMessagingChannel(channelType); if (messagingChannel == null) throw new IllegalStateException("Channel not defined in server session for type " + channelType + ""); String key = "C:" + destination + '@' + topic; Consumer consumer = (Consumer)topicAgents.get(key); if (consumer == null) { consumer = serviceFactory.newConsumer(messagingChannel, destination, topic); consumer.addSubscriptionListener(consumerSubscriptionListener); topicAgents.put(key, consumer); } return consumer; }