You could try blocking receiving events during the DB update, or if you cannot do that try storing the BACKGROUND_JOB event in a hash in memory so that when the record creation succeeds it checks the hash to see if the event has already been received. You can also use a hash to see if the record is currently being inserted or not to save checking if it&#39;s in the database.<div>

<br></div><div>-Steve</div><div><br></div><div><br><br><div class="gmail_quote">On 1 February 2013 11:42, Leonardo N. S. Pereira <span dir="ltr">&lt;<a href="mailto:leonardo@daitangroup.com" target="_blank">leonardo@daitangroup.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;m sending the SMS via mod_socket interface using the following command:<br>
     bgapi chat sip|+17778882233|external/+<a href="mailto:17778882234@sms-proxy.com">17778882234@sms-proxy.com</a>|SMS<br>
test<br>
The SMS is sent successfully.<br>
The problem is that I need to inject an string to be retrieved when the<br>
BACKGROUND_JOB event is received.<br>
<br>
This is the scenario:<br>
#1 Send an SMS using BGAPI<br>
#2 create a new record in database using the JOB_ID as key<br>
#3 As soon as the BACKGROUND_JOB event is received, update the database.<br>
<br>
The problem is that sometimes, the event is received before the record<br>
has being created.<br>
<br>
<br>
Is there any way to inject an kind of &quot;trakcing_id&quot; when sending an SMS<br>
that will be received in BG event? (just in case, for calls I had the<br>
same problem, and I used the parameter &#39;origination_channel_name&#39; to<br>
handle the problem)<br>
<br>
Thanks in advance.<br>
Leo<br>
<br>
<br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br></div>