我正在尝试使用嵌入式HornetQ服务器创建两个Spring Boot应用程序的静态集群.一个应用程序/服务器将处理外部事件并生成要发送到消息队列的消息.另一个应用程序/服务器将侦听消息队列并处理传入消息.由于两个应用程序之间的链接不可靠,因此每个应用程序将仅使用本地/ inVM客户端在其各自的服务器上生成/使用消息,并依赖于群集功能将消息转发到群集中其他服务器上的队列.
我正在使用HornetQConfigurationCustomizer自定义嵌入式HornetQ服务器,因为默认情况下它只附带一个InVMConnectorFactory.
我创建了几个说明此设置的示例应用程序,在此示例中,"ServerSend"指的是将生成消息的服务器,"ServerReceive"指的是将消耗消息的服务器.
两个应用程序的pom.xml包含:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hornetq</artifactId>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-jms-server</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
DemoHornetqServerSendApplication:
@SpringBootApplication
@EnableScheduling
public class DemoHornetqServerSendApplication {
@Autowired
private JmsTemplate jmsTemplate;
private @Value("${spring.hornetq.embedded.queues}") String testQueue;
public static void main(String[] args) {
SpringApplication.run(DemoHornetqServerSendApplication.class, args);
}
@Scheduled(fixedRate = 5000)
private void sendMessage() {
String message = "Timestamp from Server: " + System.currentTimeMillis();
System.out.println("Sending message: " + message);
jmsTemplate.convertAndSend(testQueue, message);
}
@Bean
public HornetQConfigurationCustomizer hornetCustomizer() {
return new HornetQConfigurationCustomizer() {
@Override
public void customize(Configuration configuration) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用新的命名空间jakarta而不是迁移到 Spring Boot 3 javax,但 ActiveMQ Classic 客户端尚未更新并且已被弃用。有没有办法继续使用旧的ActiveMQ客户端?
我尝试了新的 ActiveMQ Artemis 客户端,但它们似乎无法与 ActiveMQ Classic 服务器互操作。包含旧的 ActiveMQ 客户端会导致无法使用 JMSTemplate 进行配置,因为 JMSTemplate 使用 jakarta.xx 并期望ConnectionFactory来自 jakarta.xx 而不是 javax.xx
编辑:不起作用,所以唯一的方法是升级到 ActiveMQ Artemis。这样代码库也几乎没有变化。
编辑:2023 年 4 月:新的ActiveMQ 客户端发布。您只需要将spring-boot-starter-activemq与更新版本交换并包含此
当我运行此代码时,我收到此错误:
ValueError: signal only works in main thread
Run Code Online (Sandbox Code Playgroud)
我正在使用 ActiveMQ。
RealTor 是我的 Spider(selogerSpider) 的名称,它可以帮助我进行抓取。
ValueError: signal only works in main thread
Run Code Online (Sandbox Code Playgroud) 我第一次使用 JMS 和队列(Azure 队列)。我需要创建一个队列,Rubi 服务器将在其中写入一些数据,Java 将从队列中读取它并进行进一步的执行。这个过程在我的机器上本地运行良好。我创建了一个 REST 端点,它在队列中写入数据,一旦数据写入队列,侦听器将接管并读取数据并执行。当我们将它部署到 Azure 时,我在日志中看到的错误是不让队列启动
Setup of JMS message listener invoker failed for destination 'queue' - trying to recover. Cause: Identifier contains invalid JMS identifier character '-': 'x-request-id'
Run Code Online (Sandbox Code Playgroud)
Zipkin 也作为分布式跟踪系统出现在 Azure 服务器上,我猜这x-request-id与产生问题的 Zipkin 有关。我在谷歌上搜索过这个问题,但不明白为什么会发生。
以下是详细的错误信息:
[36mc.m.s.l.NextGenRequestLoggingFilter [0;39m [2m:[0;39m
Before request [uri=/services/deal-service/api/v2/deals/ack;headers=
[x-request-id:"2d8d86d7-4fbf-9db6-8e95-28813f21a85c",
x-envoy-internal:"true", x-b3-parentspanid:"a209cdc649b0b890", content-
length:"575", x-forwarded-proto:"http", postman-token:"ad074595-
76a5-474b-9711-7e071b12b3b0", x-b3-sampled:"1", x-forwarded-
for:"10.244.2.1", accept:"*/*",
authorization: "some-token-YJc4tg--34jPRziJNSACqNQ", x-b3-
traceid:"6b40ff22781be67ba209cdc649b0b890", x-b3-
spanid:"702684ddb62cfe6b",
host:"portal-gateway.52.228.65.225.nip.io",
cache-control:"no-cache", accept-encoding:"gzip, deflate, br",
user-agent:"PostmanRuntime/7.22.0",
Content-Type:"application/xml;charset=UTF-8"]]
2020-02-18T15:19:34.197666458Z [2m2020-02-18 15:19:34.197[0;39m .
[32mDEBUG
[,6b40ff22781be67ba209cdc649b0b890,702684ddb62cfe6b,true][0;39m . …Run Code Online (Sandbox Code Playgroud) 我使用Celery同一个RabbitMQ服务器。我有一个发布者,该发布者可能会被终止,SIGKILL并且由于无法观看此信号,因此我无法撤消任务。在发布者不再活跃的情况下,撤销任务的常见方法是什么?
我在工作人员端进行了间隔试验,但是发布者显然未注册为工作人员,因此我不知道如何检测到超时
我遇到了一个问题,即执行器探测 JMS 运行状况失败,即使我的路由可以连接并向 JMS 生成消息。简而言之,执行器说它已关闭,但它正在工作。
技术堆栈和技术说明:
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory连接工厂。我的路线就像筹码一样简单:
<route id="timer-cluster-producer-route">
<from uri="timer:producer-ticker?delay=5000"/>
<setBody>
<groovy>
result = ["Name":"Johnny"]
</groovy>
</setBody>
<marshal>
<json library="Jackson"/>
</marshal>
<to uri="ref:jms-producer-cluster-event" />
</route>
Run Code Online (Sandbox Code Playgroud)
基于 XML 的 Artemis 配置
由于 Spring-boot 支持基于 java 的配置,我正忙于相应地迁移我们的 XML beans。因此,我将一个工作 beans.xml 文件粘贴到项目中并启动了路由,我可以发送消息流,并且运行状况检查返回正常。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="jmsConnectionFactory"
class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<property name="user" value="artemis"/>
<property name="password" value="artemis"/>
<property name="connectionLoadBalancingPolicyClassName" value="org.apache.activemq.artemis.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy"/>
</bean>
<!--org.messaginghub.pooled.jms.JmsPoolConnectionFactory-->
<!--org.apache.activemq.jms.pool.PooledConnectionFactory-->
<bean id="jmsPooledConnectionFactory"
class="org.apache.activemq.jms.pool.PooledConnectionFactory"
init-method="start" destroy-method="stop"> …Run Code Online (Sandbox Code Playgroud) 我有一个 Spring Boot 应用程序,其中添加了 websocket 功能,以便 websocket 客户端可以发出订阅请求以订阅 websocket 主题之外的消息。
在我的控制器的方法中,我添加了一个注释 @SubscribeMapping("/topic/mytopic")。
我的 WebSocketConfig 如下所示:
@Configuration
@ComponentScan
@EnableWebSocket
public class WebSocketConfig extends WebSocketMessageBrokerConfiguratioSupport{
@Override
public void registerStompEndpoints(StompEndpointRegistry registry){
registry.addEndpoint("/my-app")
.setAllowedOrigin("*")
.withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry){
registry.enableSimpleBroker("/topic/");
registry.setApplicationDestinationPrefixes("/");
}
}
Run Code Online (Sandbox Code Playgroud)
当我进入浏览器并输入:
http://localhost:<MY_PORT>/my-app
Run Code Online (Sandbox Code Playgroud)
然后我收到回复“欢迎使用 SockJS!”。这表明Websocket服务器确实已启动并正在运行。
但令我惊讶的是,当我使用 Postman 的 Websocket 功能并尝试使用以下网址进行 Websocket 订阅时:
ws://localhost:<MY_PORT>/my-app/topic/mytopic
Run Code Online (Sandbox Code Playgroud)
此错误记录在控制台中:无效的 SockJS 路径 /topic/mytopic - 需要有 3 个路径段
并且连接会自动断开。
我在这里做错了什么吗?请指教。
根据此文档,我必须能够通过以下 URL 访问 ActiveMQ 控制台:http://localhost:8161/console
我通过 Spring Boot 应用程序在嵌入式模式下使用 ActiveMQ。ActiveMQ 工作正常,但我无法访问http://localhost:8161/console
如何配置嵌入的 Spring Boot 和 ActiveMQ 以便能够访问 Web 控制台?
我下载并解压了最新的ActiveMQ版本5.17.1。我使用的是 Java 11.0.11 和 Windows 10 Enterprise Build:19044.1706。
当我通过启动 ActiveMQ 时,.\bin\activemq.bat start我得到了这个FileNotFoundException:
WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: C:\Programs\apache-activemq-5.17.1\bin\..\data\kahadb only has 21729 mb of usable space. - resetting to maximum available disk space: 21729 mb
WARN | Temporary Store limit is 51200 mb (current store usage is 0 mb). The data directory: C:\Programs\apache-activemq-5.17.1\bin\..\data only has 21728 mb of usable space. - resetting to maximum available disk …Run Code Online (Sandbox Code Playgroud) 我有一个用于 ActiveMQ-Artemis 的 k8 部署(使用 minikube)。在此,我公开了代理(61616)和控制台(8161)的端口。将端口指向服务。它运行良好。我还为控制台配置了入口控制器。
服务.yaml
kind: Service
metadata:
name: artemis-service
spec:
type: ClusterIP
ports:
- port: 8161
name: http-console
protocol: TCP
targetPort: 8161
- port: 61616
name: netty-connector
protocol: TCP
targetPort: 61616
selector:
app: artemis
Run Code Online (Sandbox Code Playgroud)
Ingress.yaml
kind: Ingress
metadata:
name: broker-ingress
labels:
name: broker-ingress
spec:
ingressClassName: nginx
rules:
- host: artemis.broker.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: artemis-service
port:
number: 8161
Run Code Online (Sandbox Code Playgroud)
当我点击时,我可以访问 activemq 控制台,http://artemis.broker.com
现在我想使用 NGINX 控制器公开 TCP 端口 (61616),通过它我可以使用 TCP URL 将消息发布/消费到 …
spring-boot ×5
java ×2
python ×2
apache-camel ×1
azure ×1
azure-queues ×1
celery ×1
hornetq ×1
jms ×1
kubernetes ×1
minikube ×1
rabbitmq ×1
stomp ×1
web-scraping ×1
websocket ×1
zipkin ×1