简体   繁体   English

通过REST的ActiveMQ处理消息

[英]ActiveMQ Handling Messages thru REST

I am new to ActiveMQ, we had a ActiveMQ Server else where location, we are unable to connect thru tcp socket, But able to cousume the message using REST command 我是ActiveMQ的新手,我们在其他位置有ActiveMQ Server,我们无法通过tcp套接字进行连接,但是能够使用REST命令收集消息

http://admin:admin@localhost:8161/api/message?destination=queue://orders.input

I have 99K+ messages in ActiveMQ, need consume using REST command and need to store in a text file, 我在ActiveMQ中有99K +条消息,需要使用REST命令进行消费,并且需要存储在文本文件中,

import static com.jayway.restassured.RestAssured.given;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.dnb.e2e.automation.util.CommonUtil;
import com.dnb.e2e.automation.util.WebServiceUtil;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.config.SSLConfig;
import com.jayway.restassured.config.SessionConfig;
import com.jayway.restassured.response.Headers;
public class MQwithRest {
     public static String getResponse() throws Exception 
     {
        String url = "http://admin:admin@localhost:8161/api/message?destination=queue://SAMPLEQUEUE";

        String response = "a";

            while(response!=""){
            try {
                response =  given().header("content-type", "application/json")
                        .request()
                        .config(RestAssured.config().sslConfig(new SSLConfig().allowAllHostnames()))
                        .when().get(url).asString();
                System.out.println(response);
            } catch (Exception e) {
                e.printStackTrace();
            }
            }
            return "empty";
        }

     public static void main(String args[]) throws Exception
     {
                 System.out.println(MQwithRest.getResponse());
     }
}

In the above code i am displaying consumed messages at output side. 在上面的代码中,我在输出端显示消耗的消息。 When I am implementing thru rest i am able to consume only one message at a time per session. 当我实施“通过休息”时,每个会话一次只能使用一条消息。

Can any body help for Consuming 99k+ message with in a single session using REST service? 任何机构都可以使用REST服务在单个会话中帮助消耗99k +消息吗?

You can also tunnel JMS client over HTTP . 您还可以通过HTTP隧道JMS客户端 That way, you can get bypass any non-HTTP restrictions in your network and still use the JMS terminology. 这样,您可以绕过网络中的任何非HTTP限制,并仍然使用JMS术语。

Using the rest web app bundled you are a bit limited to the semantics of retrieving messages. 使用捆绑在一起的其余Web应用程序,您会有点局限于检索消息的语义。 Anyway, you should be able to get all messages using plain HTTP/Rest anyway. 无论如何,无论如何,您都应该能够使用纯HTTP / Rest获取所有消息。 Simply use a loop to get messages. 只需使用循环即可获取消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM