/** * Constructs a subscription which will execute the given callback every * time a new message arrives. * * @param subscriptionId the ID of the subscription * @param frameChannel the frame channel to write all messages for the * subscription * @param consumer the consumer to receive messages * @param session the session that created the consumer */ public ClientSubscription(String subscriptionId, WritableFrameChannel frameChannel, HazelcastMQConsumer consumer, HazelcastMQContext session) { super(); this.subscriptionId = subscriptionId; this.consumer = consumer; this.context = session; this.frameChannel = frameChannel; consumer.setMessageListener(this); }
@Override public void setMessageListener(MessageListener messageListener) throws JMSException { this.messageListener = messageListener; if (messageListener == null) { mqConsumer.setMessageListener(null); } else { mqConsumer.setMessageListener(new ConvertingMessageListener()); } }
/** * Constructs the relayer which will immediately create a context and begin * listening for messages. */ public TopicMessageRelayer() { context = createContext(); consumer = context.createConsumer(TXN_TOPIC_QUEUE_DESTINATION); consumer.setMessageListener(this); }
public DemoQueueReader(HazelcastMQInstance hazelcastMQInstance) { mqContext = hazelcastMQInstance.createContext(); mqConsumer = mqContext.createConsumer("/queue/demo.queue"); mqConsumer.setMessageListener(new HazelcastMQMessageListener() { @Override public void onMessage(HazelcastMQMessage msg) { log.info("Read data: {}", msg.getBodyAsString()); } }); }
/** * Constructs the reply manager which will listen for replies on the given * destination. If the destination is null, a temporary reply queue will be * created and managed by the reply manager. * * @param replyToDest the reply to destination or null * @param mqInstance the HzMq instance brokering all replies */ public ReplyManager(String replyToDest, HazelcastMQInstance mqInstance) { this.pendingReplyMap = new ConcurrentHashMap<>(); this.nextExpiration = new AtomicLong(Long.MAX_VALUE); this.mqContext = mqInstance.createContext(); mqContext.setAutoStart(false); // If we don't have an exclusive reply queue, create a temporary queue. this.replyToDestination = replyToDest == null ? mqContext.createTemporaryQueue() : replyToDest; this.mqConsumer = mqContext.createConsumer(this.replyToDestination); mqConsumer.setMessageListener(this); }
/** * Constructs the consumer. The consumer will not start listening for * messages until it is started. * * @param config the component configuration * @param endpoint the endpoint that the consumer belongs to */ public SingleThreadedConsumer(HazelcastMQCamelConfig config, HazelcastMQCamelEndpoint endpoint) { this.mqContext = config.getHazelcastMQInstance().createContext(); this.mqContext.setAutoStart(false); this.mqConsumer = mqContext.createConsumer(endpoint.getDestination()); this.mqConsumer.setMessageListener(this); }
mqConsumer1.setMessageListener(this); mqConsumer2.setMessageListener(this); mqConsumer3.setMessageListener(this);
mqConsumer1.setMessageListener(this); mqConsumer2.setMessageListener(this); mqConsumer3.setMessageListener(this);
mqConsumer.setMessageListener(this);