问题标签 [jmstemplate]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2314 浏览

jaxb - Spring JMS 使用 MarshallingMessageConverter 同时支持 String 等

使用 XML 配置 - 我有MarshallingMessageConverter工作;但是,我仍然想发送一些TextMessage带有简单String值的消息。

似乎我的配置迫使我从一条沟(无自动 JAXB 编组)进入另一条沟(仅 JAXB 编组):

这是我的相关 XML 配置:

JAXB 编组工作正常,但有时我想发送一个空正文(仅限标头属性)消息;这会导致如下错误:

这是有道理的,因为我在正文中发送了一个非 JAXB 字符串(或什么都没有)。

有没有可能两全其美?-and-的String, byte[],Map转换行为?org.springframework.jms.support.converter.SimpleMessageConverterorg.springframework.jms.support.converter.MarshallingMessageConverter

@JmsListener通过与另一个转换器创建第二个容器工厂并在我的注释中明确使用它来实现这一点的唯一方法是什么?

0 投票
1 回答
5751 浏览

testing - Spring jmsTemplate 发送单元测试不起作用

我的服务方法如下所示,我试图模拟 JmsTemplate 以便它可以在单元测试期间发送消息,但它不执行 jmsTemplate.send(...),它直接转到下一行,我该如何执行 jmsTemplate .send(..) 使用单元测试的我的服务类代码的一部分?

这是我的测试类代码。

我有以下接收消息的代码,但是我得到的状态对象为空。

下面的测试代码:

0 投票
0 回答
710 浏览

jms - 为本地测试 Jetty 配置 MQ Call

我成功地在我的 websphere 服务器上进行了 MQ 调用。但是我很难在本地码头服务器上做同样的工作。由于 jms 错误,我什至无法在本地启动我的服务器。

我在 websphere 服务器上配置了两个 jndi 名称:

ConnectionFactory- jms/connectionFactory

队列 - jms/cardAcquireQueue

以下是 bean 条目的代码:-

以上在服务器上工作正常。但是对于码头,我在码头有以下代码:-

我没有从 jms/ConnectionFactory 收到错误,但使用 jms/cardAcquireQueue 我收到返回 null 错误。

你能帮助如何为 jms 队列配置 jndi 名称吗?

0 投票
1 回答
2537 浏览

jms - ActiveMQ - 自动删除 incative 队列中的所有消息

我想自动删除队列中在指定时间内处于非活动状态的所有消息(当时没有新消息到达)。

我不想从代码中显式清空队列,也不想显式调用 purge ,如此所述。

这里描述的配置也不适合我的情况,因为它只会自动删除空队列,而我的队列不是空的。

是否有任何已知的 ActiveMQ 配置可以自动执行该任务?

0 投票
2 回答
345 浏览

java - 如何使用 JMS 模板从通过 MQ 接收的消息中删除 JMS 阅读器

我正在尝试使用 JmsTemplate 从 IBM 消息队列中读取一条消息并在控制台上显示该消息,但是当它被打印时,我观察到 JMS 标头也与我的消息一起附加,如下所示:

有人可以帮我编写如何删除此标头的代码,我在 Java 中使用 Spring Batch,我需要将从 MQ 接收到的消息传递给没有标头的处理器。

0 投票
2 回答
2768 浏览

java - Spring JMS 模板 - 并发调用

我可以使用 Spring 进行并发调用JMSTemplate吗?

我想并行进行 4 个外部服务调用,并且正在探索使用 SpringJMSTemplate并行执行这些调用并等待执行完成。

我正在查看的另一个选项是使用ExecutorService.

使用其中一个有什么优势吗?

0 投票
1 回答
3662 浏览

spring - WebSphere Application Server 上的 Spring JmsTemplate 和连接 jndi 查找

我正在使用 JmsTemplate 向 IBM MQ 队列发送和接收消息。我的应用程序安装在 WebSphere 应用程序服务器 8.5 上,为了检索连接,我使用了 jndi 查找。

我的春豆:

我的 Java 类:

我想知道这是否是正确的方法,我有一些问题:

  1. 建议添加 CachingConnectionFactory 还是应用服务器本身管理 che 连接?
  2. 这是使用 JmsTemplate 的正确方法吗?如果同时调用两次 MqServerDao 的“写入”方法是否安全?或者我会在“写”和“读”方法中创建一个新的 JmsTemplate 实例吗?
0 投票
1 回答
1366 浏览

spring-mvc - 如何使用 Spring 3.05 和 JBoss 5.1 (JBossMQ) 实现 JMS 本地队列?

有一个基于Spring 3.0.5框架的应用程序在JBoss 5.1 服务器上运行。

我尝试按照本教程进行操作,但它使用ActiveMQ代理而不是JBossMQ(默认 JBoss 5.1 代理)。

我已经在J​​Boss配置(destinations-service.xml)中设置了一个名为MyQueue的队列:

您可以在下面看到我的其余配置。我错过了什么?如何指定队列的 JNDI 名称和连接工厂?那么服务器地址([ConnectionFactory] ​​Connector bisocket://localhost:4457)呢?

我在 applicationContext.xml 中的配置如下:

我的制片人

我的消费者

0 投票
1 回答
1065 浏览

java - Integration testing of JMS

I have a suite of integration tests, which creates a full Spring context for my application, mocks out the end points towards other application and runs tests, for instance calling a REST-service and then check the result in the database, that other web/REST-services has been called, and so on.

On of the cases I would like to test is consumation of JMS messages, using Spring Integration. For these test cases, I create an in-memory ActiveMQ broker, place a message on it, and check that the consumation of the message has the desired the result. This approach has a problem that I can't find a good solution for.

Since the message processing happens in thread separate from my test exection, I have to wait for some time before verifying the behaviour. Right now I do this by Thread.sleep, but I'm not really happy about it. First, it adds build time, and secondly it is prone to random errors if set too low. This results in each of these tests sleeping for 2 seconds just to be sure.

Is there a way I can control whether a message has been processed? A way to check the ActiveMQ broker through JmsTemplate perhaps?

0 投票
2 回答
1864 浏览

jms - Spring jms 到 Websphere MQ 连接错误

AppConfig.xml 设置:

我收到以下错误:

我想知道的是,我们需要配置的代码或 Websphere MQ 中的某些设置是否存在问题?在向我们的 Websphere MQ 管理员提出问题之前,我想确保这不是程序中的错误(顺便说一下,他是 Websphere MQ 的新手)

我们正在使用:

  • Websphere MQ 版本 9

  • Spring JMS 版本 4.2.4.RELEASE

我使用 MQ 客户端连接到 MQ,并且能够连接(通过命令行):

但是为什么同一个用户在通过 WAS 连接时不能工作?