PL/SQL notification / DBMS_AQ.REGISTER

There have been a number of discussions on this forum about PL/SQL notifications. I'm running
into the same problem:
- create the notification procedure
- register the procedure
- enqueue a message
- NOTHING HAPPENS
It seems that the notification procedure is not executed.
The discussions on this forum were all inconclusive. Did anybody get this to work? If yes, can
you post an example (i.e. a script that creates the queue, create the procedure, registers the
procedure and enqueues a message)?
Is there a table/view that contains the registrations?
What system parameters are relevant to this functionality?
Where are errors in calling the notification procedure logged?

There are few problems that I can see with your code.
Your callback procedure header should look like this:
create or replace procedure QCallBack1(
context RAW,
reginfo SYS.AQ$_REG_INFO,
descr SYS.AQ$_DESCRIPTOR,
payload VARCHAR2,
payloadl NUMBER) is
BEGIN
END ;
And your callback notification does not include the name of the QUEUE subscriber. The first parameter
to the AQ$_REG_INFO should be of this format: <QUEUE ADMIN>.<QUEUE_NAME>:<QUEUE SUBSCRIBER>
When you say this:
sys.aq$_reg_info('myprofile.Que1',dbms_aq.namespace_aq, 'plsql://myprofile.QCallBack1', hextoraw('FF'));
You are not putting the name of the queue subscriber into the first parameter.
Also, Your callback notification URL must be like this:
'plsql://<user containing the callback proc>.<name of the callback proc>?PR=1'
Note that if the callback procedure is in another schema, you must grant EXECUTE priv. to the user
where the QUEUE has been setup.
Hallo,
I have got the same problem as Erwin Groenendal. I wrote single user que and procedures to enque and deque as simple as I can do.
pseudocode:
1. create and start que - no error
2. create proc for callback in pl/sql - no error
3. register callback - no error
4. enque message - noerror (no callback called)
5. deque message - noerror
in callback procedure I am writing into my own table with one varchar2 column to determine if the callback was processed.
My register procedure looks like: (pseudocode point 3)
procedure Register
is
XRegProc sys.aq$_reg_info;
XRegList sys.aq$_reg_info_list;
begin
XRegProc := sys.aq$_reg_info('myprofile.Que1', dbms_aq.namespace_aq, 'plsql://myprofile.QCallBack1', hextoraw('FF'));
XRegList := sys.aq$_reg_info_list(XRegProc);
dbms_aq.register(XRegList, 1);
end;
in definition variable XRegProc I tryed all possibilities like:
'plsql://myprofile.QCallBack1'
'plsql://myprofile.QCallBack1?PR=0'
'plsql://QCallBack1'
'plsql://myprofile.QCallBack1'
and so on.
The Callback looks like:
procedure QCallBack1(
context out raw,
reginfo out sys.aq$_reg_info,
descr out sys.aq$_descriptor,
payload out raw,
payloadl out number)
is
begin
insert into MyOwnTable (my_text) values ('Message notification callback called.');
commit;
end;
with compilation i have not problems. I am running oracle 9i release 2.
the enque procedure looks like:
procedure put(
APayload in raw,
ACorrelation in varchar2)
is
XEnq_opts dbms_aq.enqueue_options_t;
XMsg_props dbms_aq.message_options_t;
XMsg_id raw(16);
begin
XMsg_props.correlation := ACorrelation;
dbms_aq.enqueue('Que1', XEnq_opts, XMsg_props, APayload, XMsg_id);
commit;
end;
All rights are corectly sets under SYSTEM user.
Please help somebody why it does not work. I not see problem byt I need to call some procedure when new message arive into que. I need to have paralel process, I can not solve it with loops and so on.
Thanks for every ideas. In next week I can show you source code. Today I can not.
Regards, Zdenek.
For Oracle9i and above DBMS_AQ.REGISTER can be used for PL/SQL callback notification.
If running earlier version of Oracle, use DBMS_AQ.LISTEN to get a similar functionality.
It depends upon the URL that you specify while registering, that decides if callback will be executed or
not.
If you post the code fragment(s) of how you created the notification procedure and how you registered it,
maybe we can look to see if it is correct.
There have been a number of discussions on this forum about PL/SQL notifications. I'm running
into the same problem:
- create the notification procedure
- register the procedure
- enqueue a message
- NOTHING HAPPENS
It seems that the notification procedure is not executed.
The discussions on this forum were all inconclusive. Did anybody get this to work? If yes, can
you post an example (i.e. a script that creates the queue, create the procedure, registers the
procedure and enqueues a message)?
Is there a table/view that contains the registrations?
What system parameters are relevant to this functionality?
Where are errors in calling the notification procedure logged?

Similar Messages

  • Plsql callback (dbms_aq.register) stops working

    we had, for quite a while, a working situation where a incoming message notifies a plsql procedure, which dequeues and handles the message, resulting in a response message in a different queue
    the queue has one subscriber and through dbms_aq.register I registered a plsql callback and all worked fine for about a year
    suddenly this stopped working - messages aren't dequeued anymore - for no apparent reason (nothing changed in this part of the database)
    I already dropped and recreated the queue table, queues, subscriptions and registered the plsql callback again, but no results
    does anyone have a clue where to look (specific sys tables/views, database parameters etc) because I am running out of ideas...
    we are running the 10.2.0.1.0 database
    greatings
    Jan

    Jan,
    The EMNO (Event Monitor) process is responsible to execute the AQ notifications, in this case your pl/sql callback. This may or may not be your problem. I'm not sure how much help this link will be but it covers Event Monitor issues for various versions of Oracle. https://metalink.oracle.com/metalink/plsql/f?p=130:14:2721106654994549115::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,105067.1,1,1,1,helvetica
    Jason

  • Performance of AQ when using callback procedure (using PL/SQL notification)

    I am enqueueing XMLType in AQ.XML file is large in size.NOw I want to dequeue the AQ using PL/SQL notification(using callback procedure which will call DBMS_AQ.DEQUEUE to dequeue the AQ and process the XML.After fetching the data from XML ,I want to store these data in another table columns).
    Please suggest,In this case which approach would be better to dequeue the AQ table :
    1.PL/SQL notification(using callback procedure)
    OR
    2.Scheduling the call to DBMS_AQ.DEQUEUE to dequeue the AQ table
    What would be the impact on performance of above two approaches?

    Hi,
    The question of performance is not down to the technique one employes to enqueue/dequeue, but at a basic level, is relative to the number of messages!
    The is what the Oracle documentation states:
    >
    When persistent messages are enqueued, they are stored in database tables. The performance characteristics of queue operations on persistent messages are similar to underlying database operations. The code path of an enqueue operation is comparable to SELECT and INSERT into a multicolumn queue table with three index-organized tables. The code path of a dequeue operation is comparable to SELECT, DELETE, and UPDATE operations on similar tables.
    >
    So, if anything, the dequeue is a fraction more time & resource consuming. However, it is only a "fraction". You could always add multiple subscribers to dequeue if you want!
    You could ofcourse choose to have non-persistent messages if your application does not need the kind of fault-tolerance that persistent messaging offers, which speed things up, but only a bit, so don't get too excited about it!
    There are other things to consider however, which you may wish to read up on before getting bogged down on whether you should use notification or the scheduler:
    - Is your system clustered?
    - Concurrency on a single queue (i.e. multiple enqueues/dequeues, but single queue)
    - Propogation latency issues
    Read about these and much more at:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/perform.htm
    Finally, whether you pl/sql notification or not and whether you use dbms_scheduler is down to your application requirements!
    P;

  • Queue Concurrent Processing using PL/SQL notification

    I have a queue that I need to have the processing done concurrently no matter how many messages are in the queue.  Currently one 1 message is processed at a time, but I need at least 10 processed at once.  Each message could take up to 3 minutes to process so doing one at a time is taking too long when the number of messages grows to more than 5 or 10.  How can this be done?
    begin
      DBMS_AQADM.CREATE_QUEUE_TABLE
      ( queue_table => 'z3.health_check_qtab',
        queue_payload_type =>  'z3.sil_queue_msg_typ',
        multiple_consumers => TRUE );
      DBMS_AQADM.CREATE_QUEUE
      ( queue_name => 'HEALTH_CHECK_Q',
        queue_table => 'z3.health_check_qtab');
      DBMS_AQADM.START_QUEUE
      (  queue_name => 'HEALTH_CHECK_Q');
    end;
    begin
      dbms_aqadm.add_subscriber
      ( queue_name => 'Z3.HEALTH_CHECK_Q',
        subscriber => sys.aq$_agent( 'HC_recipient1', null, null ) );
    end;
    BEGIN
      dbms_aq.register
      ( sys.aq$_reg_info_list(
        sys.aq$_reg_info('Z3.HEALTH_CHECK_Q:HC_RECIPIENT1',
                         DBMS_AQ.NAMESPACE_AQ,
                        'plsql://Z3.Z_IMPACT_LIST_PKG.DEQUEUE_HEALTH_CHECK',
                        HEXTORAW('FF')) ) ,
      1 );
    end;
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

    I'm also looking into how to do this (on 10gR2 RAC). I would like to enqueue say 1,000,000 requests and have 10-30 (configurable) worker 'threads' dequeueing and executing a PL/SQL procedure during certain parts of the day.

  • Are  DBMS_AQ.REGISTER callbacks functional on Oracle XE?

    I'm trying to get callbacks for oracle streams to work on ORACLE XE. I'd like to be able to perform a
    demo of using JMS to fire a pl/sql procedure. There are a million other ways of doing this, I'm sure.
    The idea is to enqueue a message and have the callback fire off. The call back is created using DBMS_AQ.REGISTER
    All I seem to get is the messages in thetopic/queue, and they don't go anywhere, my procedure is not called.
    I fixed up my XE instance to support JMS data types.
    Below is the code that I've used so far. The aq_tm_processes value is 1 and the
    job_queue_processes is 10. I've called START_TIME_MANAGER for what that's worth.
    I'm missing something or XE can't do this, any help appreciated.
    =================================
    grant connect, resource, aq_administrator_role to jmsuser identified by jmsuser;
    grant execute on sys.dbms_aqadm to jmsuser;
    grant execute on sys.dbms_aq to jmsuser;
    grant execute on sys.dbms_aqin to jmsuser;
    grant execute on sys.dbms_aqjms to jmsuser;
    exec dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','jmsuser');
    exec dbms_aqadm.grant_system_privilege('DEQUEUE_ANY','jmsuser');
    CREATE ROLE my_aq_adm_role;
    grant connect, resource, aq_administrator_role to my_aq_adm_role;
    CREATE ROLE my_aq_user_role;
    GRANT aq_user_role to my_aq_user_role ;
    GRANT my_aq_user_role to jmsuser;
    dbms_aqadm.create_queue_table(
    queue_table => 'test_topic_table',
    comment => 'test topic_table',
    multiple_consumers => TRUE,
              compatible => '9.0.0',
    Queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
    message_grouping => DBMS_AQADM.TRANSACTIONAL );
    DBMS_AQADM.CREATE_QUEUE (Queue_name => 'jmsuser.test_topic',
    queue_type => DBMS_AQADM.NORMAL_QUEUE,
    max_retries => 3,
    retry_delay => 3,
    retention_time => 0,
    comment=>'test queue',
    auto_commit =>TRUE,
    Queue_table => 'jmsuser.test_topic_table');
    DBMS_AQADM.START_QUEUE (Queue_name => 'jmsuser.test_topic');
    DBMS_AQADM.ADD_SUBSCRIBER (
    queue_name => 'test_topic',
    subscriber => SYS.AQ$_AGENT(
    'test_topic_subscriber',
    'jmsuser.test_topic',
    NULL )
    DBMS_AQ.REGISTER (
    SYS.AQ$_REG_INFO_LIST(
    SYS.AQ$_REG_INFO(
    'test_topic:test_topic_subscriber',
    DBMS_AQ.NAMESPACE_AQ,
    'plsql://JMSUSER.TOPIC_CALLBACK',
    HEXTORAW('FF')
    1
    create or replace PROCEDURE TOPIC_CALLBACK
    context RAW,
    regInfo SYS.AQ$_REG_INFO,
    descr SYS.AQ$_DESCRIPTOR,
    payload SYS.AQ$_JMS_TEXT_MESSAGE,
    -- payload raw,
    payload1 number )
    AS
    r_dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T;
    r_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
    v_message_handle RAW(16);
    my_info VARCHAR2(4000);
    o_payload SYS.AQ$_JMS_TEXT_MESSAGE;
    BEGIN
    r_dequeue_options.msgid := descr.msg_id;
    r_dequeue_options.consumer_name := descr.consumer_name;
    DBMS_AQ.DEQUEUE( queue_name => descr.queue_name,
    dequeue_options => r_dequeue_options,
    message_properties => r_message_properties,
    payload => o_payload,
    msgid => v_message_handle );
    o_payload.get_text(my_info) ;
    INSERT
    INTO jmsuser.aq_info_table
    MESSAGE
    VALUES
    'Message ['
    || trim(my_info)
    || '] '
    || 'dequeued at ['
    || TO_CHAR( SYSTIMESTAMP, 'DD-MON-YYYY HH24:MI:SS.FF3' )
    || ']'
    COMMIT;
    END TOPIC_CALLBACK;

    I'm trying to get callbacks for oracle streams to work on ORACLE XE. I'd like to be able to perform a
    demo of using JMS to fire a pl/sql procedure. There are a million other ways of doing this, I'm sure.
    The idea is to enqueue a message and have the callback fire off. The call back is created using DBMS_AQ.REGISTER
    All I seem to get is the messages in thetopic/queue, and they don't go anywhere, my procedure is not called.
    I fixed up my XE instance to support JMS data types.
    Below is the code that I've used so far. The aq_tm_processes value is 1 and the
    job_queue_processes is 10. I've called START_TIME_MANAGER for what that's worth.
    I'm missing something or XE can't do this, any help appreciated.
    =================================
    grant connect, resource, aq_administrator_role to jmsuser identified by jmsuser;
    grant execute on sys.dbms_aqadm to jmsuser;
    grant execute on sys.dbms_aq to jmsuser;
    grant execute on sys.dbms_aqin to jmsuser;
    grant execute on sys.dbms_aqjms to jmsuser;
    exec dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','jmsuser');
    exec dbms_aqadm.grant_system_privilege('DEQUEUE_ANY','jmsuser');
    CREATE ROLE my_aq_adm_role;
    grant connect, resource, aq_administrator_role to my_aq_adm_role;
    CREATE ROLE my_aq_user_role;
    GRANT aq_user_role to my_aq_user_role ;
    GRANT my_aq_user_role to jmsuser;
    dbms_aqadm.create_queue_table(
    queue_table => 'test_topic_table',
    comment => 'test topic_table',
    multiple_consumers => TRUE,
              compatible => '9.0.0',
    Queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
    message_grouping => DBMS_AQADM.TRANSACTIONAL );
    DBMS_AQADM.CREATE_QUEUE (Queue_name => 'jmsuser.test_topic',
    queue_type => DBMS_AQADM.NORMAL_QUEUE,
    max_retries => 3,
    retry_delay => 3,
    retention_time => 0,
    comment=>'test queue',
    auto_commit =>TRUE,
    Queue_table => 'jmsuser.test_topic_table');
    DBMS_AQADM.START_QUEUE (Queue_name => 'jmsuser.test_topic');
    DBMS_AQADM.ADD_SUBSCRIBER (
    queue_name => 'test_topic',
    subscriber => SYS.AQ$_AGENT(
    'test_topic_subscriber',
    'jmsuser.test_topic',
    NULL )
    DBMS_AQ.REGISTER (
    SYS.AQ$_REG_INFO_LIST(
    SYS.AQ$_REG_INFO(
    'test_topic:test_topic_subscriber',
    DBMS_AQ.NAMESPACE_AQ,
    'plsql://JMSUSER.TOPIC_CALLBACK',
    HEXTORAW('FF')
    1
    create or replace PROCEDURE TOPIC_CALLBACK
    context RAW,
    regInfo SYS.AQ$_REG_INFO,
    descr SYS.AQ$_DESCRIPTOR,
    payload SYS.AQ$_JMS_TEXT_MESSAGE,
    -- payload raw,
    payload1 number )
    AS
    r_dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T;
    r_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
    v_message_handle RAW(16);
    my_info VARCHAR2(4000);
    o_payload SYS.AQ$_JMS_TEXT_MESSAGE;
    BEGIN
    r_dequeue_options.msgid := descr.msg_id;
    r_dequeue_options.consumer_name := descr.consumer_name;
    DBMS_AQ.DEQUEUE( queue_name => descr.queue_name,
    dequeue_options => r_dequeue_options,
    message_properties => r_message_properties,
    payload => o_payload,
    msgid => v_message_handle );
    o_payload.get_text(my_info) ;
    INSERT
    INTO jmsuser.aq_info_table
    MESSAGE
    VALUES
    'Message ['
    || trim(my_info)
    || '] '
    || 'dequeued at ['
    || TO_CHAR( SYSTIMESTAMP, 'DD-MON-YYYY HH24:MI:SS.FF3' )
    || ']'
    COMMIT;
    END TOPIC_CALLBACK;

  • ORA-32162: Read/Write SQL method not registered-for OTT

    I am trying this--
    env = Environment::createEnvironment (Environment::OBJECT);
    RegisterClasses(env);
    conn = env->createConnection (user, passwd, db);
    RegisterClasses is my mapping function; But still I am getting this error at--
    stmt->registerOutParam( 2,OCCIPOBJECT);
    I am trying to make a stored procedure call here...
    Can anyone tell me what is that I am missing?

    Hi,
    I am using OTT generated objects to pass them to my PL/SQL procedures as OUT parameters. When I call the registerOutParam() function, I get this error ORA-32162: Read/Write SQL method not registered.
    I am calling my mapping function after creating environment and before creating my stateless connection pool. But still I am getting this exception at runtime while calling registerOutParam().
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    // Creating the stateless connection pool.
    StatelessConnectionPool* scp;
    scp = env->createStatelessConnectionPool("naveen",
    "naveen",
    "//10.105.153.11:1521/pls",
    10,
    5,
    2,
    StatelessConnectionPool::HOMOGENEOUS);
    // Fetch a connection from the stateless connection pool
    conn = scp->getConnection();
    // After this, I create my Statement and call the registerOutParam() which
    // causes ORA-32162 exception.
    Please note that I do not get this error when I don't use any connection-pooling mechanism. That is, if I create an environment in OBJECT mode, call the mapping function with its pointer and create a normal Connection object (without any pooling etc), my application runs perfectly fine. E.g. if I replace the above piece of code with the code below, my application runs fine.
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    conn = env->createConnection("naveen", "naveen", "//10.105.153.11:1521/pls");
    // After this, I create my Statement and call the registerOutParam() which
    // does not give problem now and my application runs pefectly fine.
    Can anyone let me know what I am doing wrong while using the stateless connection pooling mechanism? I definitely need to use Stateless Connection Pooling and must not get connections directly from env->createConnection().
    Any help will be greatly appreciated.
    Thanks and Regards,
    Naveen

  • PL/SQL notification is not working

    Hi,
    We are using PL/SQL notification procedure to de-queue AQ in our application. Now the notification is not working in development instance whereas it is working in Live. The database parameter job_queue_processes was having value 0 in development database and it is now reset to 10. Still the problem exists. Please let us know what could be other reasons for failure of PL/SQL notification in AQ.
    Thanks
    Sreesha

    No version number.
    No DDL.
    No DML.
    No error messages.
    As already stated no clear understanding of what isn't working
    But equally important no clear understanding of what you implemented and how.
    If you want help you must be specific.

  • ORA-32162: Read/Write SQL method not registered

    Hi,
    I am using OTT generated objects to pass them to my PL/SQL procedures as OUT parameters. When I call the registerOutParam() function, I get this error ORA-32162: Read/Write SQL method not registered.
    I am calling my mapping function after creating environment and before creating my stateless connection pool. But still I am getting this exception at runtime while calling registerOutParam().
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    // Creating the stateless connection pool.
    StatelessConnectionPool* scp;
    scp = env->createStatelessConnectionPool("naveen",
    "naveen",
    "//10.105.153.11:1521/pls",
    10,
    5,
    2,
    StatelessConnectionPool::HOMOGENEOUS);
    // Fetch a connection from the stateless connection pool
    conn = scp->getConnection();
    // After this, I create my Statement and call the registerOutParam() which
    // causes ORA-32162 exception.
    Please note that I do not get this error when I don't use any connection-pooling mechanism. That is, if I create an environment in OBJECT mode, call the mapping function with its pointer and create a normal Connection object (without any pooling etc), my application runs perfectly fine. E.g. if I replace the above piece of code with the code below, my application runs fine.
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    conn = env->createConnection("naveen", "naveen", "//10.105.153.11:1521/pls");
    // After this, I create my Statement and call the registerOutParam() which
    // does not give problem now and my application runs pefectly fine.
    Can anyone let me know what I am doing wrong while using the stateless connection pooling mechanism? I definitely need to use Stateless Connection Pooling and must not get connections directly from env->createConnection().
    Any help will be greatly appreciated.
    Thanks and Regards,
    Naveen

    Hi,
    I found one workaround (not solution) to the problem.
    I used an IN OUT parameter instead of an OUT parameter in the stored procedure (though my requirement was only of an OUT parameter actually). This resulted in using the setObject() function instead of the registerOutParam() function which was throwing the ORA-32162 exception at runtime.
    I think there should be better ways in which we can pass an object as OUT parameter while also using stateless connection pooling for managing connections. Please let me know the same in case anyone knows that.
    Kind Regards,
    Naveen

  • Enable SQL Notification Services for BAM alerts , Biztalk 2010

    Hi,
    Enable SQL Notification Services for BAM alerts is greyed out.
    I need to enable bam alerts in BizTalk 2010.
    Regards,
    Sharmishtha

    Hi,
    If I understand correct, your problem is that the BAM Alerts configuration is greyed out in the BizTalk Configuration tool. If this is the problem it's due probably because you don't have the SQL Server 2005 Notification Services installed. Notification
    Services is required for BAM Alerts feature.
    You can take a look at the following link, even it's for multi-computer installation:
    http://social.technet.microsoft.com/wiki/contents/articles/1888.install-and-configure-bam-business-activity-monitoring-in-a-multi-computer-environment.aspx
    Best regards.

  • Use sql notification for console application C#

    I have developed ucma C# console application which sends IM  to users. 
    Now I want to send IM if any new entry is added in the table 
    So i want to use query notification .
    I have enabled service broker on my database .
    And I have added code for sqldepedency  in my code file.
    as follows.
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    ucmaSampleInstantMessagingCall.connectionfunction();
    public void connectionfunction()
    string connectionString = @"Data Source=PIXEL-IHANNAH2\PPINSTANCE;User ID=sqlPPUser;Password=ppuser1;Initial Catalog=Ian;";
    SqlDependency.Stop(connectionString);
    SqlConnection sqlConnection = new SqlConnection(connectionString);
    string statement = "select * from dbo.tblTest";
    SqlCommand sqlCommand = new SqlCommand(statement, sqlConnection);
    // Create and bind the SqlDependency object to the command object.
    SqlDependency dependency = new SqlDependency(sqlCommand, null, 0);
    SqlDependency.Start(connectionString);
    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
    private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
    ucmaSampleInstantMessagingCall.run()
    private void Run() { // Initialize and startup the platform. Exception ex = null; try { // Create the UserEndpoint _helper = new UCMASampleHelper(); _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Now I want to run this application in the background , so f any new entry is added it will notify my C# application and call run function.
    i tried above code but it was not working.
    Sample code is avaliableon net but it is for form application and we can see output if we run the form application .
    so if i want to run my C# application what should I do?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Configuration;
    using System.Security.Principal;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using System.Threading;
    using System.Diagnostics;
    using Microsoft.Rtc.Collaboration;
    using Microsoft.Rtc.Signaling;
    using System.Runtime.InteropServices;
    //using Microsoft.Rtc.Collaboration.Sample.Common;
    namespace UserPresence
    class UCMASampleInstantMessagingCall
    #region Locals
    // The information for the conversation and the far end participant.
    // Subject of the conversation; will appear in the center of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationSubject = "The Microsoft Lync Server!";
    // Priority of the conversation will appear in the left corner of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationPriority = ConversationPriority.Urgent;
    // The Instant Message that will be sent to the far end.
    private static String _messageToSend = "Hello World! I am a bot, and will echo whatever you type. " +
    "Please send 'bye' to end this application.";
    private InstantMessagingCall _instantMessaging;
    private InstantMessagingFlow _instantMessagingFlow;
    //private ApplicationEndpoint _applicationEndpoint;
    private UserEndpoint _userendpoint;
    private UCMASampleHelper _helper;
    private static SqlDependency dependency;
    private static string connectionString = @"Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=SSPI";
    // Event to notify application main thread on completion of the sample.
    private AutoResetEvent _sampleCompletedEvent = new AutoResetEvent(false);
    #endregion
    #region Methods
    /// <summary>
    /// Instantiate and run the InstantMessagingCall quickstart.
    /// </summary>
    /// <param name="args">unused</param>
    //private string _helper;
    //UCMASampleHelper _helper = new UCMASampleHelper();
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    var connection = new SqlConnection(connectionString);
    SqlDependency.Start(connectionString);
    SqlConnection connection = new SqlConnection(connectionString);
    connection.Open();
    SqlCommand command = new SqlCommand(
    "select col1 from dbo.tblTest",
    connection);
    // Create a dependency (class member) and associate it with the command.
    dependency = new SqlDependency(command, null, 5);
    // Subscribe to the SqlDependency event.
    dependency.OnChange += new OnChangeEventHandler(onDependencyChange);
    // start dependency listener
    SqlDependency.Start(connectionString);
    //ucmaSampleInstantMessagingCall.Run();
    private static void onDependencyChange(Object o, SqlNotificationEventArgs args)
    run();
    private void Run()
    // Initialize and startup the platform.
    Exception ex = null;
    try
    // Create the UserEndpoint
    _helper = new UCMASampleHelper();
    _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Console.Write("The User Endpoint owned by URI: ");
    Console.Write(_userendpoint.OwnerUri);
    Console.WriteLine(" is now established and registered.");
    List<string> _Users = new List<string>();
    _Users.Add("sip:[email protected]");
    _Users.Add("sip:[email protected]");
    foreach (string useruri in _Users)
    // Setup the conversation and place the call.
    ConversationSettings convSettings = new ConversationSettings();
    convSettings.Priority = _conversationPriority;
    convSettings.Subject = _conversationSubject;
    // Conversation represents a collection of modes of communication
    // (media types)in the context of a dialog with one or multiple
    // callees.
    //Convers conver =new ConversationParticipant
    Conversation conversation = new Conversation(_userendpoint, convSettings);
    InstantMessagingCall _instantMessaging = new InstantMessagingCall(conversation);
    // Call: StateChanged: Only hooked up for logging. Generally,
    // this can be used to surface changes in Call state to the UI
    _instantMessaging.StateChanged += this.InstantMessagingCall_StateChanged;
    // Subscribe for the flow created event; the flow will be used to
    // send the media (here, IM).
    // Ultimately, as a part of the callback, the messages will be
    // sent/received.
    _instantMessaging.InstantMessagingFlowConfigurationRequested +=
    this.InstantMessagingCall_FlowConfigurationRequested;
    // Get the sip address of the far end user to communicate with.
    //String _calledParty = "sip:" +
    // UCMASampleHelper.PromptUser(
    // "Enter the URI of the user logged onto Microsoft Lync, in the User@Host format => ",
    // "RemoteUserURI");
    // Place the call to the remote party, without specifying any
    // custom options. Please note that the conversation subject
    // overrides the toast message, so if you want to see the toast
    // message, please set the conversation subject to null.
    // _instantMessaging.Conversation()
    _instantMessaging.BeginEstablish(useruri, new ToastMessage("Hello Toast"), null,
    CallEstablishCompleted, _instantMessaging);
    catch (InvalidOperationException iOpEx)
    // Invalid Operation Exception may be thrown if the data provided
    // to the BeginXXX methods was invalid/malformed.
    // TODO (Left to the reader): Write actual handling code here.
    ex = iOpEx;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write actual handling code here.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    // Wait for sample to complete
    _sampleCompletedEvent.WaitOne();
    // Just to record the state transitions in the console.
    void InstantMessagingCall_StateChanged(object sender, CallStateChangedEventArgs e)
    Console.WriteLine("Call has changed state. The previous call state was: " + e.PreviousState +
    "and the current state is: " + e.State);
    // Flow created indicates that there is a flow present to begin media
    // operations with, and that it is no longer null.
    public void InstantMessagingCall_FlowConfigurationRequested(object sender,
    InstantMessagingFlowConfigurationRequestedEventArgs e)
    Console.WriteLine("Flow Created.");
    _instantMessagingFlow = e.Flow;
    // Now that the flow is non-null, bind the event handlers for State
    // Changed and Message Received. When the flow goes active,
    // (as indicated by the state changed event) the program will send
    // the IM in the event handler.
    _instantMessagingFlow.StateChanged += this.InstantMessagingFlow_StateChanged;
    // Message Received is the event used to indicate that a message has
    // been received from the far end.
    _instantMessagingFlow.MessageReceived += this.InstantMessagingFlow_MessageReceived;
    // Also, here is a good place to bind to the
    // InstantMessagingFlow.RemoteComposingStateChanged event to receive
    // typing notifications of the far end user.
    _instantMessagingFlow.RemoteComposingStateChanged +=
    this.InstantMessagingFlow_RemoteComposingStateChanged;
    private void InstantMessagingFlow_StateChanged(object sender, MediaFlowStateChangedEventArgs e)
    Console.WriteLine("Flow state changed from " + e.PreviousState + " to " + e.State);
    // When flow is active, media operations (here, sending an IM)
    // may begin.
    if (e.State == MediaFlowState.Active)
    // Send the message on the InstantMessagingFlow.
    _instantMessagingFlow.BeginSendInstantMessage(_messageToSend, SendMessageCompleted,
    _instantMessagingFlow);
    private void InstantMessagingFlow_RemoteComposingStateChanged(object sender,
    ComposingStateChangedEventArgs e)
    // Prints the typing notifications of the far end user.
    Console.WriteLine("Participant "
    + e.Participant.Uri.ToString()
    + " is "
    + e.ComposingState.ToString()
    private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e)
    // On an incoming Instant Message, print the contents to the console.
    Console.WriteLine(e.Sender.Uri + " said: " + e.TextBody);
    // Shutdown if the far end tells us to.
    if (e.TextBody.Equals("bye", StringComparison.OrdinalIgnoreCase))
    // Shutting down the platform will terminate all attached objects.
    // If this was a production application, it would tear down the
    // Call/Conversation, rather than terminating the entire platform.
    _instantMessagingFlow.BeginSendInstantMessage("Shutting Down...", SendMessageCompleted,
    _instantMessagingFlow);
    _helper.ShutdownPlatform();
    _sampleCompletedEvent.Set();
    else
    // Echo the instant message back to the far end (the sender of
    // the instant message).
    // Change the composing state of the local end user while sending messages to the far end.
    // A delay is introduced purposely to demonstrate the typing notification displayed by the
    // far end client; otherwise the notification will not last long enough to notice.
    _instantMessagingFlow.LocalComposingState = ComposingState.Composing;
    Thread.Sleep(2000);
    //Echo the message with an "Echo" prefix.
    _instantMessagingFlow.BeginSendInstantMessage("Echo: " + e.TextBody, SendMessageCompleted,
    _instantMessagingFlow);
    private void CallEstablishCompleted(IAsyncResult result)
    InstantMessagingCall instantMessagingCall = result.AsyncState as InstantMessagingCall;
    Exception ex = null;
    try
    instantMessagingCall.EndEstablish(result);
    Console.WriteLine("The call is now in the established state.");
    catch (OperationFailureException opFailEx)
    // OperationFailureException: Indicates failure to connect the
    // call to the remote party.
    // TODO (Left to the reader): Write real error handling code.
    ex = opFailEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    private void SendMessageCompleted(IAsyncResult result)
    InstantMessagingFlow instantMessagingFlow = result.AsyncState as InstantMessagingFlow;
    Exception ex = null;
    try
    instantMessagingFlow.EndSendInstantMessage(result);
    Console.WriteLine("The message has been sent.");
    catch (OperationTimeoutException opTimeEx)
    // OperationFailureException: Indicates failure to connect the
    // IM to the remote party due to timeout (called party failed to
    // respond within the expected time).
    // TODO (Left to the reader): Write real error handling code.
    ex = opTimeEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    // Reset the composing state of the local end user so that the typing notifcation as seen
    // by the far end client disappears.
    _instantMessagingFlow.LocalComposingState = ComposingState.Idle;
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    #endregion
    So i want to call run method when new entry is added in the database . and this application is not like any asp.net form application . In form application we display data when programs loads as like your RefreshDataWithSqlDependency
    function . But in my application my application will run (send IM) when any new entry is added in the database . As I need running application to achieve notification , what kind of changes are required?

  • How to use PL/SQL Function after registering

    Hi,
    I have successfully registered a PL/SQL Function within Discw Admin. But i don't know how to use it further??? Please let me know the steps to use it in folders (admin) or in plus.
    Actually i have a stored procedure which fetches the records from the base tables and i have to develop a report based on that data.
    Please reply ASAP.
    Thanks,
    Jay

    Hi Jay,
    If this function is a stored procedure in the right schema, you can access this function in your custom SQL like any other database functions (e.g. SUM, AVG, MAX, etc).
    If you are not using a custom folder (ie. your own SQL), you can access this function in the workbook (Tools --> Calculations --> New Button --> Select Function Radio Button --> All Functions or Database Folders.). This calculation wil become a new column in the workbook.
    Regards,
    John

  • Diference between SQL and Expert Register Assistance

    Hi experts,
    I want to performance my reports.
    I have a "Command" with SQL. ( select * from table)
    And I have a Formula in the Expert Register Assistance that is :
    {Comando.ANYO_CASO} = {?Año de Selección} or
    {Comando.ANYO_CASO} = {?Año de Selección}-1 or
    {Comando.ANYO_CASO} = {?Año de Selección}-2 or
    {Comando.ANYO_CIERRE} = {?Año de Selección} or
    {Comando.ANYO_CIERRE} = {?Año de Selección}-1 or
    {Comando.ANYO_CIERRE} = {?Año de Selección}-2 or
    What is the diference of the performance to put the Filter in the SQL or in the Expert Selection???? Because all the report is doing ...

    Ok. thank you very much.
    the problem is that I have a user entry parameters in the report: Year and Month.
    If I change the expert selection and I put the filters in the SQL Command, I have to change all the formulas in the report because all the formula reference the Year and the Month.
    Is there a way to connect the paramteres of the SQL command and the parameters of the report??? It will be super!
    do you understand me?
    Pd: May be in the expert selection I have to reference the YEAR = SQL Command YEAR?
    Edited by: Markus C. on Jul 28, 2010 2:12 PM

  • WCF-SQL notification and SQL Change Data Tracking - incompatible?

    Hi,
    I have a DB with Change Data Tracking enabled on a particular table. Each time an Update/Insert is made on this table, I'm able to check what need to be synchronised with other systems by using the CHANGETABLE function of SQL Server.
    And I want to use it with a Receive location WCF-SQL with inboundOperationType=Notification. So each time a modification is made on the table, I have a notification and I'm able to retrieve the updated/inserted records.
    Unfortunately, it seems that using the CHANGETABLE is not supported in the NotificationStatement, I got the following error: "The notification callback returned an error. Info=Invalid. Source=Statement. Type=Subscribe.".
    Any ideas to workaround?
    Thanks.

    Hi Johns-305,
    Thank you for your response.
    I'm not totally agreed with you about the notification because it depends on the situation.
    In my case, I have a table in a remote SQL database where data are not changing often. But I want to retrieve the changes as fast as I can because it needs to be synchronised with a MDM. 
    The notification is great for me because I get a notification message just after a change and I can synchronise it. Of course, if my receive location is down I can't receive the notification but with the mechanism described in the MSDN article you pointed,
    I can get the changes I missed during the outage.
    And now I have a solution to use the notification and the Data Change tracking: I use a regular SELECT statement in the notification statement (SELECT <columns> FROM MYTABLE). If something changes in the table, I got a notification and then I send
    a SELECT FROM CHANGETABLE(MYTABLE, ...) and I store the number of the last modification I got. So I can retrieve only the changes that occurs since my previous call.

  • Error deploying data tier application to SQL Azure at "Registering metadata for database" step ... should I care?

    I'd like to move an on-premesis SQL Server Database to SQL Azure. I've used SQL Mgmt Studio to Extract Data Tier Application and save my db as a dacpac file. Now I'm connected to my Azure server and I've chosen to Deploy Data Tier Application. I select my
    dacpac and the deploy starts but then on the last step "Registering metadata for database" it times out. I've tried it a couple of times and each time the deployed database is there and appears to be fully populated, but I'm not sure if I can ignore
    that error and continue. What is supposed to happen in that step, and should I expect it to fail when deploying to SQL Azure? 
    I'm following the steps here http://msdn.microsoft.com/en-us/library/hh694043.aspx in the Using Migration Tools > Data-tier Application DAC Package section, except that to deploy there's no SQL Mgmt Studio > Object Explorer [server]
    > Management >"Data Tier Applications" node, so I'm deploying by right-clicking on the server name and choosing "Deploy Data-tier Application". 
    My (total) guess here is that it's deployed the database fine and it's doing whatever magic happens when you register a data tier application, except that it's not working for SQL Azure. 
    I'm running against a server created for the new Azure service tiers, not against a Web/Business edition server. 
    The full details of error I get are below. 
    thanks, 
    Rory
    TITLE: Microsoft SQL Server Management Studio
    Could not deploy package.
    Warning SQL0: A project which specifies SQL Server 2008 as the target platform may experience compatibility issues with SQL Azure.
     (Microsoft.SqlServer.Dac)
    ADDITIONAL INFORMATION:
    Unable to register data-tier application: Unable to reconnect to database: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft.Data.Tools.Schema.Sql)
    Unable to reconnect to database: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft.Data.Tools.Schema.Sql)
    Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft SQL Server, Error: -2)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.9213&EvtSrc=MSSQLServer&EvtID=-2&LinkId=20476
    The wait operation timed out
    BUTTONS:
    OK

    Hello,
    The registration process creates a DAC definition that defines the objects in the database, and register the DAC definition in the master system database in Windows Azure SQL Database.
    Based on the error message, there is timeout error when connect to SQL Database. Did you deploy a large database? When move large data to Azure SQL Database, it is recommended to use SQL Server Integration Services (SSIS) and BCP utility.
    Or you can try to create a client application with the Data-Tier Application Framework (DACFx) client tool to import database and handle connection loss it by re-establish the connection.
    Reference: http://sqldacexamples.codeplex.com/
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • SQL Notification Firing Erratically

    Hello everyone and thanks for your help in advance.  I am wokring on a SignalR application.  Within the hub, I have the following code:
        Private Sub dependency_OnChange(sender As Object, e As SqlNotificationEventArgs)
            Dim nHub As New NotificationHub()
            nHub.SendNotifications()
        End Sub
    This works but fires multiple multiple times for any single record operation.  I then tried:
        Private Sub dependency_OnChange(sender As Object, e As SqlNotificationEventArgs)
            If e.Type = SqlNotificationType.Change Then
                Dim nHub As New NotificationHub()
                nHub.SendNotifications()
            End If
        End Sub
    However, this causes no notification to be issued.  Upon checking, I found the e.Type was equal to "Subscribe".  I then changed the code to utilize SqlNotificationInfo:
            If e.Info = SqlNotificationInfo.Insert _
            Or e.Info = SqlNotificationInfo.Delete _
            Or e.Info = SqlNotificationInfo.Update Then
                     Dim nHub As New NotificationHub()
                     nHub.SendNotifications()  
            End If
    However, this doesn't fire either.  I'm not really sure where to go next.  Any help would be greatly appreciated.

    Hi kmcnet,
    Thank you for your question. I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    If you have any feedback on our support, please click
    here.
    Regards,
    Elvis Long
    TechNet Community Support

Maybe you are looking for