You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Piotr Klimczak (JIRA)" <ji...@apache.org> on 2014/08/06 15:31:13 UTC

[jira] [Comment Edited] (AMQ-5220) Advisory messages are still empty when received with a Stomp subscription

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

Piotr Klimczak edited comment on AMQ-5220 at 8/6/14 1:31 PM:
-------------------------------------------------------------

Yes, sure.
But just was curious what was the reason.
So the problem is combination of 2 reasons:
1. Stomp ProtocolConverter expects the stomp client to directly subscribe advisory addresses. So it will work when subscribing topic is prefixed with "ActiveMQ.Advisory."
2. Statistics plugin is kind of unique advisory system, as instead if directly subscribing advisory topic, you need to send a message with reply-to header. So when reply-to header and your reply topic has a name without "ActiveMQ.Advisory." prefix, then it fails as translator finder is assuming that destination (or rather source) is not and advisory one. It simply ueses wrong frame translator. It thinks that it is a byte or string message while it is map message.

So this method is source of this issue:
{code}
    protected FrameTranslator findTranslator(String header, ActiveMQDestination destination) {
        FrameTranslator translator = frameTranslator;
        try {
            if (header != null) {
                translator = (FrameTranslator) FRAME_TRANSLATOR_FINDER
                        .newInstance(header);
            } else {
                if (destination != null && AdvisorySupport.isAdvisoryTopic(destination)) {
                    translator = new JmsFrameTranslator();
                }
            }
        } catch (Exception ignore) {
            // if anything goes wrong use the default translator
        }

        if (translator instanceof BrokerContextAware) {
            ((BrokerContextAware)translator).setBrokerContext(brokerContext);
        }

        return translator;
    }

{code}

So I will try to prepare both: unit test and fix for this problem.

Greetings
Piotr Klimczak


was (Author: nannou9):
Yes, sure.
But just was curious what was the reason.
So the problem is combination of 2 reasons:
1. Stomp ProtocolConverter expects the stomp client to directly subscribe advisory addresses. So it will work when subscribing topic is prefixed with "ActiveMQ.Advisory."
2. Statistics plugin is kind of unique advisory system, as instead if directly subscribing advisory topic, you need to send a message with reply-to header. So when reply-to header and your reply topic has a name without "ActiveMQ.Advisory." prefix, then it fails as translator finder is assuming that destination (or rather source) is not and advisory one. It simply ueses wrong frame translator. It thinks that it is a byte or string message while it is map message.

So I will try to prepare both: unit test and fix for this problem.

Greetings
Piotr Klimczak

> Advisory messages are still empty when received with a Stomp subscription
> -------------------------------------------------------------------------
>
>                 Key: AMQ-5220
>                 URL: https://issues.apache.org/jira/browse/AMQ-5220
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Transport
>    Affects Versions: 5.x
>         Environment: ActiveMQ 5.9.1, Sun Java 1.7.0_51, Ubuntu Linux
>            Reporter: Vladislav Krakhalev
>             Fix For: WAITING_FOR_TEST
>
>
> The subject of this task similiar as AMQ-2098. Bug still exists, and it can be reproduced according to steps below.
> This simple script written in PHP uses standard Stomp client
> {code}
> $stomp       = new \Stomp('tcp://localhost:61613', 'admin', 'admin');
> $stomp->subscribe('/topic/stats');
> $stomp->begin($transaction = microtime(true));
> $status = $stomp->send('/queue/ActiveMQ.Statistics.Destination.testqueue', '', Array('reply-to' => '/topic/stats', 'persistent' => 'true'));
> $message = $stomp->readFrame();
> $stomp->ack($message->headers['message-id']);
> $stomp->commit($transaction);
> {code}
> And in $message we'll have empty body paramter. It's because ActiveMQ returned message without body that's show in a captured packets between ActiveMQ and PHP communication below
> {code}
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> CONNECT
> login:admin
> passcode:admin
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> .
> T 127.0.0.1:61613 -> 127.0.0.1:53988 [AP]
> CONNECTED
> heart-beat:0,0
> session:ID:amneziac-59996-1402320672417-5:8
> server:ActiveMQ/5.9.1
> version:1.0
> .
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> SUBSCRIBE
> ack:client
> destination:/topic/stats
> activemq.prefetchSize:1
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> .
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> BEGIN
> transaction:1402321825.9952
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> .
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> SEND
> reply-to:/topic/stats
> persistent:true
> destination:/queue/ActiveMQ.Statistics.Destination.testqueue
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> .
> T 127.0.0.1:61613 -> 127.0.0.1:53988 [AP]
> MESSAGE
> message-id:ID:amneziac-59996-1402320672417-2:1:0:0:8
> type:Advisory
> destination:/topic/stats
> timestamp:1402321826311
> expires:0
> priority:4
> .
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> ACK
> message-id:ID:amneziac-59996-1402320672417-2:1:0:0:8
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> .
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AP]
> COMMIT
> transaction:1402321825.9952
> T 127.0.0.1:53988 -> 127.0.0.1:61613 [AFP]
> .
> DISCONNECT
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)