-
Notifications
You must be signed in to change notification settings - Fork 30
[Issue 53][PulsarSpout] Adds DLQ support in PulsarSpout of the Storm adapter #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
cba7ef7
c27bf74
f887d47
9a4c355
3ccacbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,6 +159,21 @@ public void ack(Object msgId) { | |
| } | ||
| } | ||
|
|
||
| public void negativeAck(Object msgId) { | ||
| if (msgId instanceof Message) { | ||
| Message<?> msg = (Message<?>) msgId; | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug("[{}] Received negative ack for message {}", spoutId, msg.getMessageId()); | ||
| } | ||
| consumer.negativeAcknowledge(msg); | ||
| pendingMessageRetries.remove(msg.getMessageId()); | ||
| // we should also remove message from failedMessages but it will be | ||
| // eventually removed while emitting next | ||
| // tuple | ||
| --pendingAcks; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void fail(Object msgId) { | ||
| if (msgId instanceof Message) { | ||
|
|
@@ -183,8 +198,13 @@ public void fail(Object msgId) { | |
| --pendingAcks; | ||
| messagesFailed++; | ||
| } else { | ||
| LOG.warn("[{}] Number of retries limit reached, dropping the message {}", spoutId, id); | ||
| ack(msg); | ||
| if(pulsarSpoutConf.shouldNegativeAckFailedMessages()){ | ||
| LOG.warn("[{}] Number of retries limit reached, negative acking the message {}", spoutId, id); | ||
| negativeAck(msg); | ||
| } else { | ||
| LOG.warn("[{}] Number of retries limit reached, dropping the message {}", spoutId, id); | ||
| ack(msg); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -325,7 +345,13 @@ public void declareOutputFields(OutputFieldsDeclarer declarer) { | |
|
|
||
| private boolean mapToValueAndEmit(Message<byte[]> msg) { | ||
| if (msg != null) { | ||
| Values values = pulsarSpoutConf.getMessageToValuesMapper().toValues(msg); | ||
| Values values; | ||
| try{ | ||
| values = pulsarSpoutConf.getMessageToValuesMapper().toValues(msg); | ||
| } catch (Exception e){ | ||
|
||
| LOG.error("[{}] Error mapping message to values", msg.getMessageId(), e); | ||
| return false; | ||
| } | ||
| ++pendingAcks; | ||
| if (values == null) { | ||
| // since the mapper returned null, we can drop the message and | ||
|
|
@@ -447,6 +473,11 @@ public void acknowledgeAsync(Message<?> msg) { | |
| consumer.acknowledgeAsync(msg); | ||
| } | ||
|
|
||
| @Override | ||
| public void negativeAcknowledge(Message<?> msg) { | ||
| consumer.negativeAcknowledge(msg); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws PulsarClientException { | ||
| consumer.close(); | ||
|
|
@@ -477,6 +508,11 @@ public void acknowledgeAsync(Message<?> msg) { | |
| // No-op | ||
| } | ||
|
|
||
| @Override | ||
| public void negativeAcknowledge(Message<?> msg) { | ||
| // No-op | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws PulsarClientException { | ||
| try { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be rename as
msgUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just following the same approach used in the
ackandfailmethods in the same class, where the method argument is calledmsgIdand has the typeObject. But inside the method, there is a check on whethermsgIdis an instance of theMessageclass and then is type cast into theMessagetype and assigned to a variable calledmsg.Do you still want me to rename the argument to some other name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdhabalia Any comments on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, let's rename it to
msgas it's not msgIdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed it to
msg