How to see when google pub/sub completes










1















From a client, I have the following code:



publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(project_id, topic_name)
future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))


Is there a way to check when the item has finished being processed? If so, how would that be done? Now, I have not way of knowing if someone 'works' or not.










share|improve this question






















  • Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

    – Kamal Aboul-Hosn
    Nov 14 '18 at 5:24











  • @KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

    – David542
    Nov 14 '18 at 5:31















1















From a client, I have the following code:



publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(project_id, topic_name)
future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))


Is there a way to check when the item has finished being processed? If so, how would that be done? Now, I have not way of knowing if someone 'works' or not.










share|improve this question






















  • Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

    – Kamal Aboul-Hosn
    Nov 14 '18 at 5:24











  • @KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

    – David542
    Nov 14 '18 at 5:31













1












1








1








From a client, I have the following code:



publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(project_id, topic_name)
future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))


Is there a way to check when the item has finished being processed? If so, how would that be done? Now, I have not way of knowing if someone 'works' or not.










share|improve this question














From a client, I have the following code:



publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(project_id, topic_name)
future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))


Is there a way to check when the item has finished being processed? If so, how would that be done? Now, I have not way of knowing if someone 'works' or not.







python google-cloud-platform google-cloud-pubsub






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 5:17









David542David542

32.9k92252457




32.9k92252457












  • Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

    – Kamal Aboul-Hosn
    Nov 14 '18 at 5:24











  • @KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

    – David542
    Nov 14 '18 at 5:31

















  • Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

    – Kamal Aboul-Hosn
    Nov 14 '18 at 5:24











  • @KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

    – David542
    Nov 14 '18 at 5:31
















Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

– Kamal Aboul-Hosn
Nov 14 '18 at 5:24





Do you mean that you want to know that the publish has completed and Pub/Sub has received the message or do you mean that you want to know that subscribers have received the message and finished processing it?

– Kamal Aboul-Hosn
Nov 14 '18 at 5:24













@KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

– David542
Nov 14 '18 at 5:31





@KamalAboul-Hosn both -- actually. But the main thing is that the item has been finished being processed by the server.

– David542
Nov 14 '18 at 5:31












2 Answers
2






active

oldest

votes


















3














To know that the message has been published successfully, you would need to look at the result of the future. The preferred way is to do this asynchronously:



def callback(future):
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
future.add_done_callback(callback)


You can also do this synchronously if you want. Calling result() on the future will block until the result of the publish is available:



future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))


There is not a built-in way to know when subscribers have finished processing the message. Requiring publishers to know when subscribers have processed messages is an anti-pattern; publishers and subscribers are meant to separate entities that aren't directly aware of each other. That being said, if you need this kind of information, the best way to do it is by setting up a second topic where your original subscribers publish messages when they have finished processing that your original publishers can subscriber to in order to know when the processing is complete.






share|improve this answer























  • thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

    – David542
    Nov 14 '18 at 6:05











  • It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:15


















0














One way to set this up is to store it a database based on the message_id. For example, here is some example server code:



def callback(message):

# Message has been received by the Server/Subscriber
cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))
connection.commit()

# Message is processed by the Server/Subscriber
data_obj = loads(message.data)
_process(data_obj)

# Message has finished being processed by the Server/Subscriber
cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))
connection.commit()
message.ack()


The client has access to the id via the future.result(), so can easily query that to see the status. This can be especially helpful if viewing statuses in a separate process (for example, if 100 long-running processes are running and we want to keep track of which have been completed).






share|improve this answer

























  • You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:09











  • @KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

    – David542
    Nov 14 '18 at 6:10












  • @KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

    – David542
    Nov 14 '18 at 6:12











  • As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:19










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293601%2fhow-to-see-when-google-pub-sub-completes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














To know that the message has been published successfully, you would need to look at the result of the future. The preferred way is to do this asynchronously:



def callback(future):
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
future.add_done_callback(callback)


You can also do this synchronously if you want. Calling result() on the future will block until the result of the publish is available:



future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))


There is not a built-in way to know when subscribers have finished processing the message. Requiring publishers to know when subscribers have processed messages is an anti-pattern; publishers and subscribers are meant to separate entities that aren't directly aware of each other. That being said, if you need this kind of information, the best way to do it is by setting up a second topic where your original subscribers publish messages when they have finished processing that your original publishers can subscriber to in order to know when the processing is complete.






share|improve this answer























  • thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

    – David542
    Nov 14 '18 at 6:05











  • It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:15















3














To know that the message has been published successfully, you would need to look at the result of the future. The preferred way is to do this asynchronously:



def callback(future):
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
future.add_done_callback(callback)


You can also do this synchronously if you want. Calling result() on the future will block until the result of the publish is available:



future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))


There is not a built-in way to know when subscribers have finished processing the message. Requiring publishers to know when subscribers have processed messages is an anti-pattern; publishers and subscribers are meant to separate entities that aren't directly aware of each other. That being said, if you need this kind of information, the best way to do it is by setting up a second topic where your original subscribers publish messages when they have finished processing that your original publishers can subscriber to in order to know when the processing is complete.






share|improve this answer























  • thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

    – David542
    Nov 14 '18 at 6:05











  • It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:15













3












3








3







To know that the message has been published successfully, you would need to look at the result of the future. The preferred way is to do this asynchronously:



def callback(future):
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
future.add_done_callback(callback)


You can also do this synchronously if you want. Calling result() on the future will block until the result of the publish is available:



future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))


There is not a built-in way to know when subscribers have finished processing the message. Requiring publishers to know when subscribers have processed messages is an anti-pattern; publishers and subscribers are meant to separate entities that aren't directly aware of each other. That being said, if you need this kind of information, the best way to do it is by setting up a second topic where your original subscribers publish messages when they have finished processing that your original publishers can subscriber to in order to know when the processing is complete.






share|improve this answer













To know that the message has been published successfully, you would need to look at the result of the future. The preferred way is to do this asynchronously:



def callback(future):
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))

future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
future.add_done_callback(callback)


You can also do this synchronously if you want. Calling result() on the future will block until the result of the publish is available:



future = publisher.publish(topic_path, data=json.dumps(dict(op='create_master', review_id=1273612)))
try:
print(future.result()) # future.result() is the message ID for the published message.
except Exception as e:
print("Error publishing: " + str(e))


There is not a built-in way to know when subscribers have finished processing the message. Requiring publishers to know when subscribers have processed messages is an anti-pattern; publishers and subscribers are meant to separate entities that aren't directly aware of each other. That being said, if you need this kind of information, the best way to do it is by setting up a second topic where your original subscribers publish messages when they have finished processing that your original publishers can subscriber to in order to know when the processing is complete.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 6:00









Kamal Aboul-HosnKamal Aboul-Hosn

3,8381321




3,8381321












  • thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

    – David542
    Nov 14 '18 at 6:05











  • It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:15

















  • thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

    – David542
    Nov 14 '18 at 6:05











  • It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:15
















thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

– David542
Nov 14 '18 at 6:05





thanks for this answer, this is really helpful. I've done a very simple database approach to store the messageID to keep track of when the message was received and processed. Does that approach seem reasonable?

– David542
Nov 14 '18 at 6:05













It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:15





It depends on the use case. The main difference between using Pub/Sub for acks and using a database is in the query model. If you use a database, you have to explicitly query to determine if a message has been processed. If you use Pub/Sub and a subscriber in your publisher then you get the acks as soon processing is done. If you are doing some kind of offline reconciliation process, the database would work well. But at that point, you might not need to use Pub/Sub at all; just have your publishers write to the database and have your subscribers query the database for messages to process.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:15













0














One way to set this up is to store it a database based on the message_id. For example, here is some example server code:



def callback(message):

# Message has been received by the Server/Subscriber
cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))
connection.commit()

# Message is processed by the Server/Subscriber
data_obj = loads(message.data)
_process(data_obj)

# Message has finished being processed by the Server/Subscriber
cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))
connection.commit()
message.ack()


The client has access to the id via the future.result(), so can easily query that to see the status. This can be especially helpful if viewing statuses in a separate process (for example, if 100 long-running processes are running and we want to keep track of which have been completed).






share|improve this answer

























  • You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:09











  • @KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

    – David542
    Nov 14 '18 at 6:10












  • @KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

    – David542
    Nov 14 '18 at 6:12











  • As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:19















0














One way to set this up is to store it a database based on the message_id. For example, here is some example server code:



def callback(message):

# Message has been received by the Server/Subscriber
cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))
connection.commit()

# Message is processed by the Server/Subscriber
data_obj = loads(message.data)
_process(data_obj)

# Message has finished being processed by the Server/Subscriber
cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))
connection.commit()
message.ack()


The client has access to the id via the future.result(), so can easily query that to see the status. This can be especially helpful if viewing statuses in a separate process (for example, if 100 long-running processes are running and we want to keep track of which have been completed).






share|improve this answer

























  • You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:09











  • @KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

    – David542
    Nov 14 '18 at 6:10












  • @KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

    – David542
    Nov 14 '18 at 6:12











  • As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:19













0












0








0







One way to set this up is to store it a database based on the message_id. For example, here is some example server code:



def callback(message):

# Message has been received by the Server/Subscriber
cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))
connection.commit()

# Message is processed by the Server/Subscriber
data_obj = loads(message.data)
_process(data_obj)

# Message has finished being processed by the Server/Subscriber
cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))
connection.commit()
message.ack()


The client has access to the id via the future.result(), so can easily query that to see the status. This can be especially helpful if viewing statuses in a separate process (for example, if 100 long-running processes are running and we want to keep track of which have been completed).






share|improve this answer















One way to set this up is to store it a database based on the message_id. For example, here is some example server code:



def callback(message):

# Message has been received by the Server/Subscriber
cursor.execute('INSERT IGNORE INTO pubsub (id, message, received) VALUES (%s, %s, NOW())', (message.message_id, message.data))
connection.commit()

# Message is processed by the Server/Subscriber
data_obj = loads(message.data)
_process(data_obj)

# Message has finished being processed by the Server/Subscriber
cursor.execute('UPDATE pubsub SET completed=NOW() WHERE id=%s', (message.message_id,))
connection.commit()
message.ack()


The client has access to the id via the future.result(), so can easily query that to see the status. This can be especially helpful if viewing statuses in a separate process (for example, if 100 long-running processes are running and we want to keep track of which have been completed).







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 6:10

























answered Nov 14 '18 at 6:04









David542David542

32.9k92252457




32.9k92252457












  • You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:09











  • @KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

    – David542
    Nov 14 '18 at 6:10












  • @KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

    – David542
    Nov 14 '18 at 6:12











  • As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:19

















  • You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:09











  • @KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

    – David542
    Nov 14 '18 at 6:10












  • @KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

    – David542
    Nov 14 '18 at 6:12











  • As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

    – Kamal Aboul-Hosn
    Nov 14 '18 at 6:19
















You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:09





You probably want to ack the message after updating the database. Otherwise, if your subscriber process crashes before the update occurs, you will not receive the message again and therefore your entry in the database will never be marked completed.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:09













@KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

– David542
Nov 14 '18 at 6:10






@KamalAboul-Hosn that makes sense -- thanks for the note (edited above).

– David542
Nov 14 '18 at 6:10














@KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

– David542
Nov 14 '18 at 6:12





@KamalAboul-Hosn is the above approach a common (or at least reasonable) pattern to keep track of pub/sub? Do most users of pub/sub care when items are sent/received, etc.?

– David542
Nov 14 '18 at 6:12













As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:19





As I mention in my answer, having publishers that need to know when messages have completed processing by subscribers is considered an anti-pattern. It couples the two in a way that is not the preferred way to use Pub/Sub. One of the main points of the paradigm is the decoupling of publishers and subscribers. So whether or not it is reasonable really depends on what the publishers (or other services) are doing with this information.

– Kamal Aboul-Hosn
Nov 14 '18 at 6:19

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293601%2fhow-to-see-when-google-pub-sub-completes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線