When I want to get the parameter returned by the consumer after sending the message, there is no way to get it.
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 142
Description
When I want to get the parameter returned by the consumer after sending the message, there is no way to get it.
**Describe the solution you'd like**
I want to know whether the consumer can transmit such custom parameters in consumption, and query the corresponding parameters through messageId.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
I thought about alternatives like this:
Send another message through the consumer end, send the logic to consume the message, I use the interceptor to intercept the key to consume the corresponding data, I do not know whether it is reasonable, just contact, there are many mistakes, please forgive
`Producer producer = client.newProducer()
.topic("cn.flyrise.workflow/todo/reply_message")
.create();
MessageId messageId = producer.newMessage()
.key(id)
.value("test reply")
.send();
//拦截器
ConsumerInterceptor interceptor = new ConsumerInterceptor() {
@Override
public void close() {
}
@Override
public Message beforeConsume(Consumer consumer, Message message) {
if(!id.equals(message.getKey())){
return null;
}
return message;
}
@Override
public void onAcknowledge(Consumer consumer, MessageId messageId, Throwable cause) {
}
@Override
public void onAcknowledgeCumulative(Consumer consumer, MessageId messageId, Throwable cause) {
}
@Override
public void onNegativeAcksSend(Consumer consumer, Set messageIds) {
}
@Override
public void onAckTimeoutSend(Consumer consumer, Set messageIds) {
}
};
Consumer consumer = client.newConsumer()
.topic("persistent://cn.flyrise.workflow/todo/reply_message")
.intercept(new ConsumerInterceptor[]{interceptor})
.subscriptionType(SubscriptionType.Shared)
.subscriptionName("foo")
.subscribe();
while (true){
Message message = consumer.receive();
if(message!=null){
System.out.println("Consumer message:"+new String(message.getData()));
consumer.closeAsync();
return Reply.success(new String(message.getData()));
}
}`
Contributor guide
Research direction
Start by reading the Java Producer, Consumer, MessageId, and ConsumerInterceptor APIs shown in the issue, focusing on how a consumer response could be associated with the sent message. Define whether custom consumer parameters can be transmitted and queried by MessageId, and document or test the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100