我想知道如何根据建议使用 ActiveMQ 进行测试的答案使用 ActiveMQ 测试JMS 模拟 JMS - jUnit
但是,我没有从 MessageConsumer 收到我期望的消息。如果我使用接收它就挂在那里。
这是我的代码
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.Assert;
import org.junit.Test;
public class JmsTest {
@Test
public void test() throws Exception {
final ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"vm://localhost?broker.persistent=true");
final Queue queue;
final Connection connection = connectionFactory.createConnection();
final Session session = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
{
queue = session.createQueue("test");
}
{
final MessageProducer producer = session.createProducer(queue);
final TextMessage message …Run Code Online (Sandbox Code Playgroud) http://docs.oracle.com/javaee/1.4/api/javax/jms/Session.html#createTopic(java.lang.String ) 此 API 表示session.createTopic(topicname)不适用于创建物理主题。这是什么意思?
如果我希望一组具有“admin”权限的用户负责创建主题,另一组具有“write”权限的用户负责向该主题发布消息,我该如何实现呢?看来后一组也必须有“admin”的权限,因为他们必须使用这个方法: session.createTopic(topicname)。
如何区分“管理”和“写入”权限?
尝试找到一种使用 jolokia api 和curl 清除AMQ 中的2 个队列的方法。在 jolokia 列表中找到了这个:
"brokerName=localhost,destinationName=FOO.CommandQueue,destinationType=Queue,type=Broker":
{ ...
"purge": {
"ret": "void",
"desc": "Removes all of the messages in the queue.",
"args": []
},
}
Run Code Online (Sandbox Code Playgroud)
但不清楚如何使用它来编写卷曲调用。有人可以给一些建议吗?
/J
我需要编写一个侦听消息队列(消费者)并将其读取的数据发送到数据库的服务器,以及另一个将信息(生产者)发布到该队列的服务器。
我正在关注Spring+JMS 上的官方 spring 参考。
我不明白以下内容:
在我看到的例子中:
FileSystemUtils.deleteRecursively(new File("activemq-data"));
Run Code Online (Sandbox Code Playgroud)
作为删除队列的一种手段。
队列的数据是否保存在文件中?
如果队列是由文件系统维护的,我如何将我的JMS服务器扩展到多于一台计算机(服务器)
谢谢!
总的来说,我对消息传递很陌生,但已经加入了一个大量使用消息传递的支持项目。
因此,该项目使用 Tibco,并且在 Tibco 中,通过使用图形 UI,将主题连接到队列非常容易。
现在我们想要转向活跃的 mq - 并且刚刚开始阅读它 - 我没有找到一种简单的方法来将主题桥接到队列
有任何想法吗 ?
谢谢
假设我有一个主题的 3 个订阅者 A、B、C,并且我希望 A、B 被视为“同一订阅者”,这意味着他们只能获得每条消息的一份副本。而 C 又拿到了一份。
我发现http://activemq.apache.org/virtual-destinations.html是一种方式。但是如果我无法更改 activemq 代理的配置怎么办?
不知道有没有什么“id”的道具,可以让两个订阅者当做一个吗?喜欢 kafka 中的组 ID?
是否有 Spring AMQP + ActiveMQ(发送方 + 接收方)的工作源代码示例,而不依赖于 JMS API?
注意:出现这个问题的原因是 Spring 已经将 JMS 列为已弃用的远程传输协议(仍然积极支持 AMQP 和 Web 服务调用)。
我正在新的 Windows 2016 服务器上安装 activemq。我已经安装了最新版本的 Java“1.8.0_321”和最新下载的 activemq“5.17.0”,但是当我尝试启动 activemq 时出现此错误:
Warning: JAVA_HOME environment variable is not set.
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/activemq/console/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在apache-camel路由中读取jms头.以下是我正在阅读正文和标题的路线.
String endPointTopic = "activemq:topic:geoLoc";
String endPointTopicOut = endPointTopic + "_outbox";
from(endPointTopic)
.log("Message from Topic is ${body} & header is ${header.Action}")
.to(endPointTopicOut);
Run Code Online (Sandbox Code Playgroud)
基本上从日志中我可以看到以下内容,这意味着我能够读取正文而不是标题中的id.
来自Topic的消息是GeoLocationInfoDTO {id = 2,geoLocationUUId ='null',geoLocationName ='null',geoLocationDesc ='null',geoLocationPolygon ='null',geoLocationCenterLatitude ='null',geoLocationCenterLongitude ='null'}&header is
以下是我通过jms模板将消息发布到activeMQ的代码.
private MessageHeaders getMessageHeaders(HttpMethod action) {
log.debug("DomainPublisher : getMessageHeaders");
Map <String, Object> headerMap = new HashMap<>();
headerMap.put("Action", action);
return new MessageHeaders(headerMap);
}
public void publish(BaseDTO dto, HttpMethod action) {
log.debug("DomainPublisher : type is : {} : ", dto.getClass().getName());
getJmsMessagingTemplate().convertAndSend(topicMap.get(dto.getClass().getName()), dto, getMessageHeaders(action));
}
Run Code Online (Sandbox Code Playgroud)
注意:我还尝试将标头ID记录为$ {header.id}而不是$ {header.Action},但没有任何内容被打印出来.
我还想知道jms消息可用的所有头文件.
尝试连接到Active MQ上的队列时,我收到以下错误消息.
Failed to create route ...because of Failed to resolve endpoint: amq://queue:ROBOMQ.TO.MPM due to: Password must also be provided when using username/password as credentials.
Run Code Online (Sandbox Code Playgroud)
下面的Camel XML中的AMQ bean声明.已经工作了好几个月但现在已经停止了.
<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://127.0.0.1:61616" />
<property name="userName" value="${username}" />
<property name="password" value="${password}" />
</bean>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
activemq-classic ×10
java ×4
jms ×4
apache-camel ×2
authority ×1
curl ×1
jakarta-ee ×1
jolokia ×1
junit ×1
spring ×1
spring-jms ×1
testing ×1