<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="159887" data-post-id="159887">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sorentwo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorentwo/120/37360_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sorentwo
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Oban Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Less excited to announce the release of <a href="https://github.com/sorentwo/oban/blob/master/CHANGELOG.md#100-rc2--2020-01-22" rel="noopener nofollow ugc">Oban v1.0.0-rc.2</a>, but alas there was a bug in the V8 migration. Thanks to <a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a> for the bug report.</p>
<p>From the tiny <a href="https://github.com/sorentwo/oban/blob/master/CHANGELOG.md#100-rc2--2020-01-22" rel="noopener nofollow ugc">CHANGELOG</a></p>
<h3><a name="p-159887-fixed-1" class="anchor" href="#p-159887-fixed-1" aria-label="Heading link" rel="nofollow"></a>Fixed</h3>
<ul>
<li>[Oban.Migration] Separate adding and modifying new columns in the V8 migration. The columns can’t be modified without a <code>flush</code>.</li>
</ul>
<h3><a name="p-159887-changed-2" class="anchor" href="#p-159887-changed-2" aria-label="Heading link" rel="nofollow"></a>Changed</h3>
<ul>
<li>[Oban.Testing] Accept a custom prefix when making test assertions</li>
</ul> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="159887" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/163">Post #162</a>
	                </div>
	            </div>
              <div id="likers-container-159887" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="159887"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #162"></div>
  </section>
</div>
    <div class="postbit" id="160972" data-post-id="160972">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sorentwo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorentwo/120/37360_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sorentwo
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Oban Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Oban <a href="https://github.com/sorentwo/oban/blob/master/CHANGELOG.md#100--2020-01-29" rel="noopener nofollow ugc">v1.0.0</a> is out along with ObanWeb v1.0.1. There aren’t any changes between rc.2 and 1.0, so nothing to report from the CHANGELOG this time <img src="https://forum.elixirforum.com/images/emoji/apple/smile.png?v=15" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>
<p>This means that the API and migrations are stable and there won’t be any breaking changes (though there may be some deprecations). There is more to come! Some exciting features are <a href="https://github.com/sorentwo/oban/issues/121" rel="noopener nofollow ugc">already planned</a> and <a href="https://github.com/sorentwo/oban/pull/156" rel="noopener nofollow ugc">under development</a>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="160972" data-batch-url="/posts/batch_likers">
                        13
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/164">Post #163</a>
	                </div>
	            </div>
              <div id="likers-container-160972" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="160972"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #163"></div>
  </section>
</div>
    <div class="postbit" id="160974" data-post-id="160974">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="paulsullivanjr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/paulsullivanjr/120/14688_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  paulsullivanjr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Great! I’ll be updating today! Thank you for all the work you put into this project!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="160974" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/165">Post #164</a>
	                </div>
	            </div>
              <div id="likers-container-160974" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="160974"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #164"></div>
  </section>
</div>
    <div class="postbit" id="162055" data-post-id="162055">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="arton" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arton/120/9244_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  arton
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/sorentwo" rel="nofollow">@sorentwo</a> Thanks again for this great library, just upgraded to 1.0 with no problems.</p>
<p>I have another question <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> . I’m wondering if there is a recommended way to await the completion of a job or somehow be notified that a specific job is complete without resorting to polling. I saw the <a href="https://github.com/LostKobrakai/omen" rel="noopener nofollow ugc">omen</a> library by <a class="mention" href="/u/lostkobrakai" rel="nofollow">@LostKobrakai</a> from a few month ago which has some interesting ideas, but was wondering if there’s any built-in features I should be considering?</p>
<p>I basically want to be able to enqueue a job and then wait for it to complete before moving on the the next step in a sequence of events. For instance keeping an http connection alive while a short running job is run on another service. I’ve thought of using telemetry to be notified, but I suppose it would need to be a general process that monitors all jobs instead of something like waiting for a specific job?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162055" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/166">Post #165</a>
	                </div>
	            </div>
              <div id="likers-container-162055" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162055"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #165"></div>
  </section>
</div>
    <div class="postbit" id="162072" data-post-id="162072">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="arton" data-post="166" data-topic="22449">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arton/48/9244_2.png" class="avatar"> arton:</div>
<blockquote>
<p>I’m wondering if there is a recommended way to await the completion of a job or somehow be notified that a specific job is complete without resorting to polling.</p>
</blockquote>
</aside>
<p>I think this is achievable using existing telemetry hooks! You could register a telemetry handler on job completion events, and in that handler do a Phoenix pubsub publish. Processes that want to wait for job completion subscribe to a topic based on the job id or arg. Alternatively, you can also just do a phoenix pubsub at the end of the job.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162072" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/167">Post #166</a>
	                </div>
	            </div>
              <div id="likers-container-162072" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162072"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #166"></div>
  </section>
</div>
    <div class="postbit" id="162088" data-post-id="162088">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="arton" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arton/120/9244_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  arton
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks <a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a>, I think that’s a pretty smart way to approach it.</p>
<p>I’ve started playing with that solution, but one issue I’m having is that the service that enqueue’s the job is not the same as the worker service, so none of my telemetry events are showing up on the enqueueing service.</p>
<p>I’ve tried some different configs to get the telemetry events without subscribing as a worker but haven’t figured anything out yet. Does anyone have any ideas on how a service can receive Oban telemetry events for a queue without subscribing as a worker?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162088" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/168">Post #167</a>
	                </div>
	            </div>
              <div id="likers-container-162088" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162088"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #167"></div>
  </section>
</div>
    <div class="postbit" id="162090" data-post-id="162090">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>To be clear, telemetry isn’t pubsub, rather you use telemetry events to trigger calls over phoenix pubsub. The worker service would attach a telemetry handler on boot to the Oban events. Your handler in the worker service would then perform a publish over phoenix pubsub. The thing to figure out is: how does your enqueing service subscribe to phoenix pubsub topics within your worker service? You’ll have to elaborate on how those services communicate.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162090" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/169">Post #168</a>
	                </div>
	            </div>
              <div id="likers-container-162090" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162090"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #168"></div>
  </section>
</div>
    <div class="postbit" id="162091" data-post-id="162091">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sb8244" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sb8244/120/18642_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sb8244
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Real-Time Phoenix</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="arton" data-post="166" data-topic="22449">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arton/48/9244_2.png" class="avatar"> arton:</div>
<blockquote>
<p>I basically want to be able to enqueue a job and then wait for it to complete before moving on the the next step in a sequence of events.</p>
</blockquote>
</aside>
<p>I haven’t done this with Oban specifically (I used Sidekiq), but I think the approach could be viable here. If the enqueueing service has a known value (like a job ID or some manually generated token passed into the job), then it could subscribe to the PubSub topic like <code>"job_completed:MY_ID"</code>. A subscribed process will receive a message when it goes over the PubSub, so you’d literally just be using <code>receive</code> with a timeout that you want. I do notice that the Oban Job struct has an id field.</p>
<p>I would probably approach this by having the job itself tell your system that it’s done processing (broadcast as the final step of the job). I say this because I’d want to avoid a mix of hooks defined across the system.</p>
<p>This advice is a slight tweak on Ben’s useful advice.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162091" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/170">Post #169</a>
	                </div>
	            </div>
              <div id="likers-container-162091" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162091"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #169"></div>
  </section>
</div>
    <div class="postbit" id="162093" data-post-id="162093">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="benwilson512" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/120/1457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  benwilson512
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Craft GraphQL APIs in Elixir with Absinthe</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sb8244" data-post="170" data-topic="22449">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sb8244/48/18642_2.png" class="avatar"> sb8244:</div>
<blockquote>
<p>This advice is a slight tweak on Ben’s useful advice.</p>
</blockquote>
</aside>
<p>I actually agree that this should be probably handled as an actual part of the job’s function, instead of as a hook into Oban’s inner workings. Telemetry events are about providing insight into the working of your code as a system, if users are waiting on logical tasks to be completed that’s a business layer concern and should probably be handled at that level.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162093" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/171">Post #170</a>
	                </div>
	            </div>
              <div id="likers-container-162093" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162093"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #170"></div>
  </section>
</div>
    <div class="postbit" id="162126" data-post-id="162126">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sorentwo" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorentwo/120/37360_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sorentwo
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Oban Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>As suggested by <a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a> and <a class="mention" href="/u/sb8244" rel="nofollow">@sb8244</a>, this is definitely a place to use PubSub. You can’t rely on Telemetry because it is only single node.</p>
<p>An alternative to using Phoenix PubSub (if you don’t happen to be using it or you’d like an “Oban native” option) is to piggy back on the Postgres pubsub system that Oban uses. You can use the undocumented <a href="https://github.com/sorentwo/oban/blob/master/lib/oban/notifier.ex" rel="noopener nofollow ugc">Oban.Notifier</a> module to subscribe to messages in your worker process, like so:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyApp.WorkerA do
  use Oban.Worker

  alias Oban.{Job, Notifier}

  @impl Oban.Worker
  def perform(args, _job) do
    :ok = Notifier.listen(Notifier, [:signal])

    {:ok, %Job{id: jid}} =
      %{}
      |&gt; MyApp.WorkerB.new()
      |&gt; Oban.insert()

    wait_for_complete(jid)
  end

  defp wait_for_complete(jid) do
    # Notifications are decoded from JSON before they are pushed to your process
    payload = %{"job_complete" =&gt; jid}

    receive do
      {:notification, "oban_signal", ^payload} -&gt;
        {:ok, :finished}

      _ -&gt;
        # Wait in a loop, there may be other messages on the `oban_signal` channel
        wait_for_complete(jid)
    after
      5_000 -&gt;
        {:error, :timeout}
    end
  end
end
</code></pre>
<p>In your other worker, <code>WorkerB</code> in this example, you’d explicitly publish a message to the <code>oban_signal</code> channel.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyApp.WorkerB do
  use Oban.Worker

  @impl Oban.Worker
  def perform(args, %Oban.Job{id: jid}) do
    do_stuff_with_args(args)

    notify_complete(jid)

    :ok
  end

  # The mechanism for publishing messages is a little tricky. There used to be a `publish` function on 
  # `Oban.Notifier`, but it was removed around the time that beats were added.
  defp notify(jid) do
    # Channels are prefixed with the pg schema name, this allows isolation between mutltiple
    # instances of Oban in the same database.
    channel = "public.oban_signal"

    # The payload must be valid JSON, you could encode it instead of writing by hand.
    payload = ~s({"job_complete":#{jid}})

    MyApp.Repo.query!("SELECT pg_notify($1, $2)", [channel, payload])
  end
end
</code></pre>
<p>This has come up a few times in the past, enough that I’ve considered adding a function that abstracts all of the details here away and acts like async/await for Oban jobs. Something like <code>Oban.insert_await/3</code>, which would insert the job and block until it was complete.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="162126" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/oban-reliable-and-observable-job-processing/22449/172">Post #171</a>
	                </div>
	            </div>
              <div id="likers-container-162126" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="162126"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #171"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/22449/load_more?page=18">Load more posts (141 remaining)</a>
</div></template></turbo-stream>