activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vatsal Shah (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMQ-4692) ActiveMQ broker does not publish last will messages
Date Mon, 03 Feb 2014 06:10:09 GMT

    [ https://issues.apache.org/jira/browse/AMQ-4692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13889251#comment-13889251
] 

Vatsal Shah commented on AMQ-4692:
----------------------------------

I can't find it's Last will & testament code.
Can someone please tell me where it is defined ?

I can try to make patch.


> ActiveMQ broker does not publish last will messages
> ---------------------------------------------------
>
>                 Key: AMQ-4692
>                 URL: https://issues.apache.org/jira/browse/AMQ-4692
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, MQTT
>    Affects Versions: 5.8.0
>         Environment: win7 64 OS.
>            Reporter: greywolf
>
> When I run a MQTT client(paho or fuse)to connect ActiveMQ broker. if i terminate
this client and can not receive LWT messages from broker.
> I changed broker from ActiveMQ to Mosquitto broker , everything is ok.
> below is my test class:
> package com.paho;
> import org.eclipse.paho.client.mqttv3.MqttCallback;
> import org.eclipse.paho.client.mqttv3.MqttClient;
> import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
> import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
> import org.eclipse.paho.client.mqttv3.MqttException;
> import org.eclipse.paho.client.mqttv3.MqttMessage;
> import org.eclipse.paho.client.mqttv3.MqttSecurityException;
> import org.eclipse.paho.client.mqttv3.MqttTopic;
> public class Sub {
> 	private MqttClient mqttClient;
> 	
> 	public void subscriber(){
> 		try {
> 			mqttClient = new MqttClient("tcp://192.168.100.80:1883", MqttClient.generateClientId());
> 			
> 			MqttConnectOptions connectOptions = new  MqttConnectOptions();
> 			//set will
> 			connectOptions.setWill(mqttClient.getTopic("lastwill"), new String("I am offline").getBytes(),
1, false);
> 			mqttClient.connect(connectOptions);
> 			mqttClient.setCallback(new MqttCallback(){
> 				public void connectionLost(Throwable paramThrowable) {
> 					System.out.println("Connection Exist. \nCause: " + paramThrowable);
> 					while(true){
> 						try {
> 							Thread.sleep(20000);
> 							if(!mqttClient.isConnected()){
> 								subscriber();
> 							}
> 						} catch (InterruptedException e) {
> 							e.printStackTrace();
> 						}
> 					}
> 				}
> 				public void messageArrived(MqttTopic paramMqttTopic,
> 						MqttMessage paramMqttMessage) throws Exception {
> 					System.out.println("Message arrived From The Topic:\t"+paramMqttTopic.toString()
+" \nMessage: " + paramMqttMessage.toString());
> 				}
> 				public void deliveryComplete(
> 						MqttDeliveryToken paramMqttDeliveryToken) {
> 				}
> 				
> 			});
> 			
> 			mqttClient.subscribe("durable",1);
> //			mqttClient.subscribe("durable1",1);
> 			
> 		} catch (MqttException e) {
> 			e.printStackTrace();
> 		}
> 	}
> 	
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) {
> 		Sub sub = new Sub();
> 		sub.subscriber();
> 	}
> }



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message