CA Service Management

 View Only
  • 1.  Ways to integrate with CA SDM

    Posted Nov 10, 2016 08:12 AM

    Hello community,

    as we know there are few described ways like WebServices, bop cmd or Text API that could be used to integrate with CA SDM. But looking deeper I have found that there is a way to integrate with SDM using Java libraries located in NX_ROOT/Java/lib, for example rpc_srvr (pdm_rpc.jar located in bin folder) using slump.jar to exchange data with SDM using BPObject. which looks like have possibility to execute inner sdm methods directly from Java.

    Is anyone knows how those lib's/methods are work?

     

    PS: new instance of rpc_object, spell_object and bp_object could be called within SDM,

    I have found and explained how spell_object are work here: Execute SDM method using SPEL 

    But didn't find get to work others...



  • 2.  Re: Ways to integrate with CA SDM
    Best Answer

    Posted Nov 14, 2016 11:00 AM

    Well... I've got it!

     

    Algorithm:

    - Login to slump;

    - Register new BPServer with your own name;

    - Call methods and retrieve replies.

    - Enjoy!

     

    z_echo method source: SPEL: How to call SDM method using WebServies 

     

    Java code example attached, please beware: I'm totally new to Java, so code could be offensive.

    package eu.cdtj.sdm.slump;

    import com.ca.ServicePlus.slump.*;
    import org.apache.log4j.Logger;

    import java.io.IOException;

    /**
    * Created by cdtj on 14.11.2016.
    * cdtj71@gmail.com
    */

    public class mgr implements BPMessaging {
        private static Logger jlog = Logger.getLogger(mgr.class);
        private BPObject catcher = null;
        private static String my_name = "z_test";
        private static String catcher_name = "z_test";
        private static mgr _instance;
        private static SLUMP slump = null;
        private static ADDRESS_SLNX _domSrvr = null;

        private mgr() {
            this.catcher = new BPObject(this, catcher_name);
        }

        public static void main(String[] args) throws Throwable {
            slump = new SLUMP();
            try {
                slump.logon(my_name);
            } catch (IOException e) {
                e.printStackTrace();
            }
            slump.register_msg("SLUMP_DISCONNECTED", new CALL_BACK() {
                @Override
                public void handleIOErr() {
                    jlog.info("handleIOErr");
                }

                @Override
                public void recv(msg_NX msg_nx) {
                    jlog.info("Received MSG_NX. DestName: " + msg_nx.getDestName() + "\nSrcName:" + msg_nx.getSrcName());
                }
            });
            callMethod();
        }

        private static void callMethod() {
            _domSrvr = BPServer.top_object();
            try {
                callAttr("api", "z_echo", new String[]{"Hello", "World", "1"});
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        private static void callAttr(String factoryName, String methodName, String[] attrs) throws Exception {
            BPMessage request = new BPMessage("call_attr");
            request.add(factoryName);
            request.add(methodName);
            for (String attr : attrs) {
                request.add(attr);
            }
            BPMessage reply = request.send_wait(0, _domSrvr);
            if(reply.isError()) {
                jlog.error("Error in call_attr(" + factoryName + "):" + reply.getString(0));
                throw new Exception(reply.getString(0));
            } else {
                for (int i=0;i<reply.getNumArgs();i++) {
                    jlog.info(reply.get(i).toString());
                }
            }
        }

        @Override
        public void recvmsg(BPMessage bpMessage) { jlog.info("BPMessage received. Method:" + bpMessage.getMethod()); }

        @Override
        public BPObject getCatcher() { return null; }

        @Override
        public String getName() { return null; }

    }

     

    Output:

    [main] INFO  mgr 60 Hello
    [main] INFO  mgr 60 World
    [main] INFO  mgr 60 1

     

    Regards,

    cdtj



  • 3.  Re: Ways to integrate with CA SDM

    Posted Nov 14, 2016 12:02 PM

    Awesom, now it would be nice to find the way to execute external java library using rpc_srvr and we have total control over SDM. Nice job cdtj



  • 4.  Re: Ways to integrate with CA SDM

    Posted Nov 15, 2016 04:41 AM

    Almost done

     

    As I found execution method is same for all kind of objects/processes, firstly we need to define new object in followed structure:

    @               \\ ? pointer
    domsrvr:sa     \\ process
    TOP               \\ target object
    0               \\ hash id, 0 for new
    0               \\ was explained in spel docs published by @daniel-bighelini

    to get this structure you can call: printf((string)any_object);


    ok then,
    my process called z_test and I registered new target object TEST_MSG in slump.

    spel:

    void zobj() {
         object newobj;
         int msg_i;
         newobj = (object)((string)"@|z_test|TEST_MSG|0|0");
         printf((string)newobj);
         send_wait(5, newobj, "test");
    }

     

    We receiving message from callback interface in msg_NX format, then it can be converted to BPObject format.
    Seems I have missed something because my _instance didn't trigger receive function and I process input message manually,
    also I didn't understand yet how to reply back to SDM, so I defined timeout in send_wait in spell.

     

    java:

    slump.register_msg("TEST_MSG", new CALL_BACK() {
         @Override
         public void handleIOErr() {
              jlog.info("handleIOErr");
         }

         @Override
         public void recv(msg_NX msg_nx) {
              BPMessage bp = new BPMessage(msg_nx, _instance);
              jlog.info(bp.getMethod());
              // Output: [TCP_port-Read:Slump_nxd] INFO  mgr 65 test
              // where "test" was my called sdm method
         }
    });

     

    Regards,

    cdtj



  • 5.  Re: Ways to integrate with CA SDM

    Posted Aug 22, 2018 04:14 PM

    Hi cdtj!

     

    Important Information:
    The "pointer " usually indicated by the character  "@" indicates on which server the process will be interpreted.
    When you use the "@" character, the current server is invoked.
    Examples:
    @|domsrvr|TOP|0 = localhost
    server999|domsrvr|TOP|0 = server999


  • 6.  Re: Ways to integrate with CA SDM

    Posted Aug 23, 2018 03:35 AM

    Thank you for sharing Daniel!

    Do you have any usage scenarios for this feature? The only that came to mind is to forcibly run code on primary server while on secondaries.

    Regards,

    Timur



  • 7.  Re: Ways to integrate with CA SDM

    Posted Aug 23, 2018 07:57 AM

    Hi Timur,

     

    Example: send_wait(0, (object) "SERVERAPL1|BOP-LOGIN|validate_user|0", "session_info");

     

    This method I use to account for the amount of sessions established with each application server.

    Enjoy!