Home Forums Business Model Classes How to invoke events of a class?

Tagged: ,

Viewing 3 reply threads
  • Author
    Posts
    • #461

      Hi Team,

      What are the different ways to invoke/trigger events of a class?

      we wrapped our ‘service’ invocation inside one of the event of Class, we found below xml batch process to invoke the events of class; need info on how to test the same from local environment (using nextJ suite & Tee Server)

      Thanks,
      Aravind

      0
    • #465

      Hi Team,

      I found one of the way to invoke events from scratchpad to test as follows:
      (TestProcessClass’eventName) ; being eventName should be static and public.

      Please suggest on how to load ‘BatchProcess xml’ that got mentioned in my above post.

      Thanks,
      Aravind

      0
      • #468
        Vassiliy Iordanovvi
        Participant

        Please suggest on how to load ‘BatchProcess xml’ that got mentioned in my above post.

        If you are using the BatchBrokerFileChannel to submit the message to the service, you just have to set up the directories for the channel in the environment file, and then copy the file with the XML message to the incoming directory. Ideally, it should be done in a way that is similar to the one used by the external system that you are integrating with. One possibility is to use the Scheme I/O APIs, e.g.

        (with-output-to-file (string-append ((((invocation-context)'metadata)'getChannel "BatchBrokerFileChannel")'incomingDirectory) "/message" (cast string (cast long (now)))) (lambda (out) (display msg out)))

        0
    • #463
      Ed ShawEd Shaw
      Keymaster

      You’re right. One way to invoke an event on a class is to simply do something like:

      (MyClass'myevent arg1 arg2)

      The first part of this – MyClass – is a Class. The second part – myevent – is a symbol. The arguments are whatever is expected by the event.

      But in your message, you are only passing in strings and the arguments are variable in number, so you will have to go from string to Class, string to symbol and then apply the resulting event to the list of arguments.

      If I understand you correctly, I think you want to:

      1. specify an xml file that describes a process you want to kick off in the business model. The process, class and event already exist.

      2. receive this message over a channel to tell the server to start the process

      3. based on this, start the process

      So, I’ll assume you are using a file channel, but an HTTP channel or other would work just as well…

      1. Create a Message in the integration layer that will allow you to parse your BatchProcess xml structure above.

      2. Create a Service to process your message and kick off the process. To start just put a log step in it.

      3. Create a File Channel to receive your message and bind it to your service

      4. Add the file channel to your environment. Run your server; drop your file in the folder; check your output to see that the message was received.

      5. Update your service to do something like the following:

      I hope this helps. Ed

      1
    • #470

      Hi Team,
      As suggested, I have confugured my BatchBrokerFileChannel and placed the trigger file, that file contains as below:

      I have started the server, the below was the error received, please suggest:

      ; 13:39:02,679 ERROR [BatchBrokerService] (NexJ-Worker-17) Event "startMyProcess" on class "TestMyProcess" is not exposed for Batch Broker Service.

      Thanks
      Aravind

      0
      • #472
        Vassiliy Iordanovvi
        Participant

        Here is how to troubleshoot problems like this one:

        1) Find the error code by looking for the message in the *.strings files. In this case, looking for “is not exposed for Batch Broker Service” gives you “err.batchBrokerProcess.notExposed”

        2) Find the model file by the error code retrieved in (1). In this case, you find “BatchBrokerService.service”.

        3) In the model file, you can see what conditions trigger the error. In this case, it cannot find an instance of BatchBrokerProcess by class name and event name. The batch broker has to be configured with such an entry. One way of doing that is (re-)creating the entries in a persistence initializer (class that has the aspect PERSISTENCE_INITIALIZER and implements actions in the initializePersistence event).

        0
Viewing 3 reply threads
  • You must be logged in to reply to this topic.