From users-return-31954-apmail-activemq-users-archive=activemq.apache.org@activemq.apache.org Mon Sep 24 14:34:07 2012 Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45809DAAF for ; Mon, 24 Sep 2012 14:34:07 +0000 (UTC) Received: (qmail 85527 invoked by uid 500); 24 Sep 2012 14:34:06 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 85491 invoked by uid 500); 24 Sep 2012 14:34:06 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 85483 invoked by uid 99); 24 Sep 2012 14:34:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 14:34:06 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=URI_HEX X-Spam-Check-By: apache.org Received-SPF: unknown (athena.apache.org: error in processing during lookup of stephen.vincent@sas.com) Received: from [216.139.250.139] (HELO joe.nabble.com) (216.139.250.139) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 14:34:01 +0000 Received: from [192.168.236.139] (helo=joe.nabble.com) by joe.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1TG9j9-00020I-QB for users@activemq.apache.org; Mon, 24 Sep 2012 07:33:39 -0700 Date: Mon, 24 Sep 2012 07:33:39 -0700 (PDT) From: "Steve.V." To: users@activemq.apache.org Message-ID: <1348497219775-4656853.post@n4.nabble.com> In-Reply-To: <1348455001111-4656839.post@n4.nabble.com> References: <1347510956475-4656426.post@n4.nabble.com> <1348455001111-4656839.post@n4.nabble.com> Subject: Re: No correlation ID in HTTP header when using RESTful interface MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I modified the test program I included in my last post, so that it prints the headers. I believe this test illustrates that the correlation ID is not coming back in an HTTP header. When I run the test below, here is an example of what it prints: ---------------- Set-Cookie: JSESSIONID=b27ojdkduucinp4h2icpuu0a;Path=/demo Content-Type: text/xml;charset=UTF-8 id: ID:d22275-3589-1348496728952-1:1:1:1:1 Server: Jetty(7.6.1.v20120215) HTTP/1.1 200 OK Hello --------------- Here is the test: ------------------------------ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; public class CorrelId { public static void main( String[] args ) throws Exception { ActiveMQConnectionFactory conFac; Connection connection; Session session; Destination destination; MessageProducer producer; DefaultHttpClient httpClient; try { conFac = new ActiveMQConnectionFactory( "tcp://localhost:61616" ); connection = conFac.createConnection(); connection.start(); session = connection.createSession( false, Session.AUTO_ACKNOWLEDGE ); destination = session.createQueue( "myqueue" ); producer = session.createProducer( destination ); producer.setDeliveryMode( DeliveryMode.NON_PERSISTENT ); producer.setTimeToLive(60000); String text = "Hello"; TextMessage message = session.createTextMessage( text ); String correlId = "Resty 123"; message.setStringProperty( "correlationId", correlId ); message.setJMSCorrelationID( correlId ); producer.send( message ); httpClient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://localhost:8161/demo/message/myqueue?readTimeout=1000&type=queue&clientId=test" ); HttpResponse response = httpClient.execute(httpget); Header[] headers = response.getAllHeaders(); for ( int i = 0; i < headers.length; i++ ) System.out.println( headers[i++] ); // Examine the response status System.out.println(response.getStatusLine()); // Get hold of the response entity HttpEntity entity = response.getEntity(); if ( entity != null ) { InputStream instream = entity.getContent(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(instream)); // do something useful with the response System.out.println(reader.readLine()); } catch ( IOException ex ) { // In case of an IOException the connection will be released // back to the connection manager automatically throw ex; } catch (RuntimeException ex) { // In case of an unexpected exception you may want to abort // the HTTP request in order to shut down the underlying // connection and release it back to the connection manager. httpget.abort(); throw ex; } finally { // Closing the input stream will trigger connection release instream.close(); } // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources httpClient.getConnectionManager().shutdown(); } } catch( Exception e ) { System.out.println( e.getMessage() ); } } } --------------- ----- Stephen Vincent -- View this message in context: http://activemq.2283324.n4.nabble.com/No-correlation-ID-in-HTTP-header-when-using-RESTful-interface-tp4656327p4656853.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.