Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5DE71200BE4 for ; Wed, 21 Dec 2016 09:16:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5C76F160B26; Wed, 21 Dec 2016 08:16:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4758160B0C for ; Wed, 21 Dec 2016 09:16:14 +0100 (CET) Received: (qmail 77836 invoked by uid 500); 21 Dec 2016 08:16:13 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 77821 invoked by uid 99); 21 Dec 2016 08:16:13 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2016 08:16:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 053E9C0333 for ; Wed, 21 Dec 2016 08:16:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.521 X-Spam-Level: X-Spam-Status: No, score=-5.521 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_EU=0.5, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Q1q3Dvbs7hf9 for ; Wed, 21 Dec 2016 08:16:10 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 4BB435F474 for ; Wed, 21 Dec 2016 08:16:09 +0000 (UTC) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0AC0961BB6 for ; Wed, 21 Dec 2016 08:15:38 +0000 (UTC) Received: from localhost.localdomain ([10.40.30.127]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBL8FZK2004660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 21 Dec 2016 03:15:37 -0500 Subject: Re: Qpid QMF with qpid-jms-client 0.10.0 To: users@qpid.apache.org References: <06724697-fe46-81df-9245-6672194c1e08@redhat.com> From: Filip Nguyen Message-ID: <5a277c65-f33a-9b46-615a-8f778c947673@redhat.com> Date: Wed, 21 Dec 2016 09:15:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------3CB5CD5332D5BEA121F7186E" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 21 Dec 2016 08:15:38 +0000 (UTC) archived-at: Wed, 21 Dec 2016 08:16:15 -0000 --------------3CB5CD5332D5BEA121F7186E Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Thank you so much Chris! To sum up what changes I had to do to my code: * Supply routing key (using the trick with typecast to AmqpJmsMessageFacade). I was in fact specifically grepping the jms-client sources to find how it handles "subject", but I missed the fact that there is the qpid proton library for Java * for some strange reason remove request.setJMSType("amqp/map"); * Change the response handling as QMF now responds with JmsObjectMessage instead of MapMessage and it also uses org.apache.qpid.proton.amqp.Binary in the inner parts of the message * request.setValidatePropertyNames(false); - this one was also quite tricky, thanks I hope that migrating other parts of the code won't be as tricky as this :-) On 12/19/2016 05:40 PM, Chris Richardson wrote: > Hi Filip, > > I think I might have had the same problem as you in the past because > the methods (I think) are required are not available on the JMS > interface. My solution was a rather hacky approach of casting the JMS > instance to the actual Qpid type, as in the following examples: > > private void method(String method, Map arguments, String address) throws JMSException { > Destination reply_to = session.createTemporaryQueue(); > MessageConsumer receiver = session.createConsumer(reply_to); > > JmsMapMessage request = (JmsMapMessage) session.createMapMessage(); > request.setValidatePropertyNames(false); > request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); > request.setStringProperty("qmf.opcode", "_method_request"); > request.setStringProperty("method", "request"); > > Map object_id_map = new HashMap(); > object_id_map.put("_object_name", address); > > request.setString("_method_name", method); > > // Can't set map directly on object, so we'll hack it here > JmsMapMessageFacade facade = (JmsMapMessageFacade)request.getFacade(); > facade.put("_object_id", object_id_map); > facade.put("_arguments", arguments); > > int correlation_id = sendMessage(request, reply_to); > > List response = awaitResponse(receiver, correlation_id, 10 * 1000); > if (response != null && response.size() > 0) { > new ResponseDecoder().decodeResponse(response); > } else { > throw new JMSException("No response received"); > } > } > > private int sendRequest(String opcode, Map query, Destination replyAddress) throws JMSException { > JmsMapMessage request = (JmsMapMessage) session.createMapMessage(); > request.setValidatePropertyNames(false); > request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); > request.setStringProperty("qmf.opcode", opcode); > > // Can't set map directly on object, so we'll hack it here > JmsMapMessageFacade facade = (JmsMapMessageFacade)request.getFacade(); > for (Map.Entry entry : query.entrySet()) { > facade.put(entry.getKey(), entry.getValue()); > } > > return sendMessage(request, replyAddress); > } > > Unfortunately I haven't structured our Java implementation of the QMF2 > interface as well as I could have done and it's rather entrenched in > another of our libraries but I'm sure no one will mind if I share the > attached implementation (based on the Qpid Python implementation) for > reference. > > /Chris > > > On 19 December 2016 at 14:14, Filip Nguyen > wrote: > > We currently use Java JMS qpid-client 0.32. It is quite easy to > use QMF [1] just by using MapMessage etc. > > With new Java Qpid JMS client > org.apache.qpid:qpid-jms-client:jar:0.10.0 I couldn't find a way > how to use Qpid QMF. Is there any existing usage or example how to > do that? > > [1] > > MapMessage request = session.createMapMessage(); > request.setJMSReplyTo(responseQueue); > request.setStringProperty("x-amqp-0-10.app-id", "qmf2"); > request.setStringProperty("qmf.opcode", "_query_request"); > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org > > For additional commands, e-mail: users-help@qpid.apache.org > > > > > > -- > > *Chris Richardson*, System Architect > cr@fourc.eu > > /FourC AS, Vestre Rosten 81, Trekanten, NO-7075 Tiller, Norway > www.fourc.eu / > > *Follow us on LinkedIn , Facebook > , Google+ and Twitter > !* > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org > For additional commands, e-mail: users-help@qpid.apache.org --------------3CB5CD5332D5BEA121F7186E--