Итак, я получаю эту ошибку на стороне процесса: < /p>
2025-04-26 14:27:04,630 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel reportsqueue
2025-04-26 14:27:04,631 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-response
2025-04-26 14:27:04,632 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17007: Connection with RabbitMQ broker established for channel `reportsqueue`
2025-04-26 14:27:04,632 INFO [io.ver.rab.imp.RabbitMQClientImpl] (main) Starting rabbitmq client
2025-04-26 14:27:04,632 ERROR [io.ver.rab.imp.RabbitMQClientImpl] (executor-thread-1) Could not connect to rabbitmq: java.net.ConnectException: Connection refused
at java.base@21.0.6/sun.nio.ch.Net.pollConnect(Native Method)
at java.base@21.0.6/sun.nio.ch.Net.pollConnectNow(Net.java:682)
at java.base@21.0.6/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542)
at java.base@21.0.6/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592)
at java.base@21.0.6/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base@21.0.6/java.net.Socket.connect(Socket.java:751)
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:61)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1249)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1096)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.newConnection(RabbitMQClientImpl.java:160)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.connect(RabbitMQClientImpl.java:843)
at io.vertx.rabbitmq.impl.RabbitMQClientImpl.lambda$tryConnect$36(RabbitMQClientImpl.java:763)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$5(ContextImpl.java:205)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:270)
at io.vertx.core.impl.ContextImpl$1.execute(ContextImpl.java:221)
at io.vertx.core.impl.WorkerTask.run(WorkerTask.java:56)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:81)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:643)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base@21.0.6/java.lang.Thread.runWith(Thread.java:1596)
at java.base@21.0.6/java.lang.Thread.run(Thread.java:1583)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)
< /code>
У меня есть сервер Rabbitmq Manager, работающий на порте Localhost: 8085: 15672 для пользовательского интерфейса и порта AMQP на 5672. С помощью моего приложения.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
rabbitmq.port=5672
rabbitmq.username=team1
rabbitmq.password=team1
mp.messaging.outgoing.order-response.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
mp.messaging.outgoing.order-response.rabbitmq.port=5672
mp.messaging.outgoing.order-response.rabbitmq.username=team1
mp.messaging.outgoing.order-response.rabbitmq.password=team1
mp.messaging.incoming.reportsqueue.rabbitmq.host=rabbitmq.rabbitmq.svc.cluster.local
mp.messaging.incoming.reportsqueue.rabbitmq.port=5672
mp.messaging.incoming.reportsqueue.rabbitmq.username=team1
mp.messaging.incoming.reportsqueue.rabbitmq.password=team1
< /code>
Мой производитель настроен аналогичным образом на Application.properties, но я не получаю никаких ошибок, как показано выше: < /p>
2025-04-26 03:01:09,439 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-response
2025-04-26 03:01:09,440 INFO [io.sma.rea.mes.rabbitmq] (main) SRMSG17036: RabbitMQ broker configured to [localhost:5672] for channel order-requests
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) team1-purchase-api 1.0.3 native (powered by Quarkus 3.20.0) started in 0.025s. Listening on: http://0.0.0.0:8080
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) Profile prod activated.
2025-04-26 03:01:09,442 INFO [io.quarkus] (main) Installed features: [cdi, grpc-client, hibernate-orm, hibernate-reactive, hibernate-reactive-panache, hibernate-validator, kubernetes, messaging, messaging-rabbitmq, reactive-pg-client, rest, rest-jackson, smallrye-context-propagation, smallrye-openapi, swagger-ui, vertx]
< /code>
И вот мой код на стороне процессора: < /p>
package team1_report;
import java.time.LocalDateTime;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import io.quarkus.hibernate.reactive.panache.common.WithTransaction;
import io.smallrye.mutiny.Uni;
import org.jboss.logging.Logger;
import io.vertx.core.json.JsonObject;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class ReportProcessor {
private static final Logger LOG = Logger.getLogger( ReportProcessor.class );
@Incoming("reportsqueue")
@Outgoing("order-response")
public String handleOrderRequest(String msg) {
LOG.info("Received order-request: " + msg);
try {
JsonObject json = new JsonObject(msg);
String orderId = json.getString("order_id");
Long customerId = json.getLong("customer_id");
Long productId = json.getLong("product_id");
Long quantity = json.getLong("quantity");
Double totalAmount = json.getDouble("total_amount");
String timestamp = LocalDateTime.now().toString();
Orders order = new Orders();
order.id = orderId;
order.customerId = customerId;
order.productId = productId;
order.quantity = quantity;
order.totalAmount = totalAmount;
order.timestamp = timestamp;
return persistOrder(order)
.onItem().transform(unused -> {
JsonObject response = new JsonObject();
response.put("orderID", orderId);
response.put("customerID", customerId);
response.put("productID", productId);
response.put("quantity", quantity);
response.put("totalAmount", totalAmount);
LOG.info("Saved order and emitted order-response: " + response.encodePrettily());
return response.encode();
})
.await().indefinitely();
} catch (Exception e) {
LOG.error("Error processing order-request", e);
return "NULL - ERROR";
}
}
@WithTransaction
public Uni persistOrder(Orders order){
return order.persist().replaceWithVoid();
}
}
< /code>
Вот мои работающие стручки: < /p>
shubh@Mac Report-Microservice-Processor % kubectl get pods -n rabbitmq
NAME READY STATUS RESTARTS AGE
rabbitmq-0 1/1 Running 0 13h
shubh@Mac Report-Microservice-Processor % kubectl get pods
NAME READY STATUS RESTARTS AGE
team1-customer-68dcb85d4b-rqrbv 1/1 Running 8 (13h ago) 30h
team1-customer-client-665b678cd7-d79l7 1/1 Running 10 (22h ago) 2d15h
team1-customer-database-postgresql-0 1/1 Running 14 (22h ago) 4d22h
team1-purchase-api-94f4676cf-7pw48 1/1 Running 0 12h
team1-report-database-postgresql-0 1/1 Running 3 (22h ago) 29h
team1-report-processor-8696f4c5b4-c6vws 1/1 Running 0 3m13s
shubh@Mac Report-Microservice-Processor %
Подробнее здесь: https://stackoverflow.com/questions/795 ... h-rabbitmq