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

hebing edited comment on APLO-370 at 8/24/16 3:48 AM:
------------------------------------------------------

i try to solved it by recomplie the mqtt.jar but failed。the reason is that when 
you reconnect it with cleanSession = false,
service will not release last connect ,there will be two(maybe more)Session 
(more info see Sink.scala) for same address, 
when current working session is wrong,it will lose message, a simple way to 
solved it by create new SessionState for every connect:

modified the MqttSession.java in attach method,change it to :
...
if (false && !clean_session) {
            // Setup the previous subscriptions..
            session_state.strategy.create(host().store(), client_id);
....


hope it work for you and someone can fixed it. 


was (Author: hebing):
i try to solved it by recomplie the mqtt.jar but failed。the reason is that when 
you reconnect it with cleanSession = false,
service will not release last connect ,there will be two(maybe more)Session 
(more info see Sink.scala) for same address, 
when current working session is wrong,it will lose message, a simple way to 
solved it by create new SessionState for every connect:

modified the MqttSessionManager.java in attach method,change it to :
 
                                                        SessionState state;
                                                        //always create a 
SessionState for incomming connect,if you want to remain data from cache ,copy 
it
                            if (true || handler.connect_message.cleanSession()) 
{
                                state = 
host_state.session_states.remove(client_id);
                                if (state == null) {
                                    state = new SessionState();
                                }
                            } else {
                                state = 
host_state.session_states.get(client_id);
                                if (state == null) {
                                    state = new SessionState();
                                    host_state.session_states.put(client_id, 
state);
                                }
                            } 

hope it work for you and someone can fixed it. 

> Durable subscriptions can not work sometimes
> --------------------------------------------
>
>                 Key: APLO-370
>                 URL: https://issues.apache.org/jira/browse/APLO-370
>             Project: ActiveMQ Apollo
>          Issue Type: Bug
>          Components: apollo-mqtt
>    Affects Versions: 1.7
>         Environment: centos 6.5
>            Reporter: wanged
>
> I use durable subscriptions for mqtt. when the client connected and 
> subscripted, sometimes receive message from dsub, sometimes not receive 
> message(at this time dsub has messages, unless the client disconnect and 
> reconnect) .
> my config is:
> <broker xmlns="http://activemq.apache.org/schema/activemq/apollo"; 
> validation="strict">
>   <log_category console="console" security="security" connection="connection" 
> audit="audit"/>
>   <authentication domain="apollo"/>
>   <access_rule allow="admins" action="*"/>
>   <access_rule allow="*" action="connect" kind="connector"/>
>   <auto_gc interval="60" />
>   <virtual_host id="yey">
>     <host_name>localhost</host_name>
>     <host_name>127.0.0.1</host_name>
>     <access_rule allow="apps" action="connect create receive consume"/>
>     <access_rule allow="mgts" action="connect create send receive consume"/>
>     <dsub tail_buffer="10k" full_policy="drop head" auto_delete_after="0" 
> quota="102400"/>
>     <leveldb_store directory="/data/apollo/data"/>    
>   </virtual_host>
>   <web_admin bind="http://localhost:61680"/>
>   <connector id="tcp" bind="tcp://0.0.0.0:1883" protocol="mqtt">
>     <mqtt max_message_length ="10240" />
>   </connector>
>   <key_storage file="${apollo.base}/etc/keystore" password="password" 
> key_password="password"/>
> </broker>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to