The aim of this chapter is to create a new microservice called "Quick Start Microservice". A new microservice will be launched next to default microservices delivered with default configuration. After completing these instructions, and after start a new microservice You should see a new JVM process as in the diagram below:If You dont want write sample application code - You have got prepared java source as zip files - its exactly the same as follows --> /upload/quick_start_1_3_0.zip

If You dont want write/edit server configuration file - You have got prepared configuration files as zip files - its exactly the same as follows -> /upload/quick_start_configuration_1_3_0.zip

Import that configuration as Maven project to Your IDE. In pom.xml file java source path is set to start directory. So You can edit configuration file as typically JAVA source files. See picture below:

! Notice. Add Maven dependency like in previous chapter

Download jlupin-all-assembly library here --> jlupin-all-assembly-1.3.0.jar

Execute maven command:

mvn install:install-file -DgroupId=com.jlupin -DartifactId=jlupin-all-assembly -Dversion=1.3.0 -Dpackaging=jar -Dfile=jlupin-all-assembly-1.3.0.jar

Add dependency to main pom.xml file:

<dependencies>
 <dependency>
  <groupId>com.jlupin</groupId>
  <artifactId>jlupin-all-assembly</artifactId>
  <version>1.3.0</version>
  <scope>provided</scope>
 </dependency>
 <dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.1</version>
  <scope>test</scope>
 </dependency>
</dependencies>

Step 1:

Service interface:

package com.jlupin.quickstart.service;

public interface QuickStartService { int getRandomInt(); }

Step 2:

Interface implementation:

package com.jlupin.quickstart.service.impl;

import com.jlupin.quickstart.service.QuickStartService;
import com.jlupin.impl.util.JLupinUtil;
import com.jlupin.interfaces.container.runtime.JLupinRuntimeContainer;
import com.jlupin.interfaces.context.service.JLupinServiceContext;
import com.jlupin.interfaces.logger.JLupinLogger;
import com.jlupin.interfaces.logger.enums.LogMode;
import java.security.SecureRandom;

public class QuickStartServiceImpl implements QuickStartService {

    private JLupinLogger jLupinLogger;
    private SecureRandom secureRandom;

    public QuickStartServiceImpl() {
        jLupinLogger = JLupinRuntimeContainer.getInstance().getJLupinLogger();
        secureRandom = new SecureRandom();
    }

    public int getRandomInt() {

        JLupinServiceContext jLupinServiceContext     = JLupinUtil.getJLupinServiceContext();
        JLupinRuntimeContainer jLupinRuntimeContainer = JLupinRuntimeContainer.getInstance();

        jLupinLogger.log(1, LogMode.INFO, " operation request id:" + jLupinServiceContext.getJLupinInputParameter().getRequestId() +
                " operation session id:" + jLupinServiceContext.getJLupinInputParameter().getSessionId());

        jLupinLogger.log(2, LogMode.INFO ,"application:" + jLupinRuntimeContainer.getApplicationName() +
                " invoking service:" + jLupinServiceContext.getCurrentlyServiceName());

        return secureRandom.nextInt();
    }
}

Step 3:

Create Spring configuratgion file (path: $project/src/main/resources/spring-services.xml)__

Content of Spring's configuration file – spring-services.xml:

<import resource="spring-jlupin-default-configuration.xml"/>

<bean id="quickStartService" class="com.jlupin.quickstart.service.impl.QuickStartServiceImpl">
</bean>

Meaning of entries:
quickStartService – the service class is available remotely through name quickStartService;

NOTICE ! The above configuration file extends the default configuration file: spring-jlupin-default-configuration.xml for the application. The file is contained in catalogue SERVER_HOME/server-resources.

In this file are stored every needed util server's object - always import this file to Your app config.

If the annotation is used instead of configuration files, the configuration file will look as follows:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="spring-default-configuration.xml"/>

    <context:annotation-config/>
    <context:component-scan base-package="com.jlupin.quickstart.service.impl"/>
</beans>

The service class annotation will have the following format:

@Component("quickStartService")
public class QuickStartServiceImpl implements QuickStartService

or:

@Service("quickStartService")
public class QuickStartServiceImpl implements QuickStartService


The structure of our project should look as follows:  

Step 4:

We edit the global configuration file of the global server and add a new definition for the application - location:

SERVER_HOME/start/configuration/JLupinGlobalMultiProcessConfigurationImpl.java

The server configuration files are in the JAVA class format.

In this configuration file, the method:

public JLupinMultiProcessManager getJLupinMultiProcessManager()

is responsible for the application configuration on the server. If the server has just been downloaded, two application are defined as examples: firstSampleApplication and secondSampleApplication. We add the configuration of the third application (quickStartApplication):

JLupinLocalServerProcessConfigurator quickStartApp = new JLupinLocalServerProcessConfigurator();
        quickStartApp.setLocalServerName("localhost");
        quickStartApp.setPrimaryPort(3001);
        quickStartApp.setSecondaryPort(3002);
        quickStartApp.setPrimaryCommandPort(3003);
        quickStartApp.setSecondaryCommandPort(3004);
        quickStartApp.setConnectionSocketTimeout(30000);
        quickStartApp.setWaitForProcessStartResponseTime(45000);
        quickStartApp.setWaitForProcessDestroyResponseTime(10000);
        quickStartApp.setPrimaryJvmOptions("-Xms128M -Xmx256M");
        quickStartApp.setSecondaryJvmOptions("-Xms128M -Xmx256M");
        quickStartApp.setConfigurationClassFileName("JLupinQuickStartApplicationConfigurationImpl.java");
…
 jLupinDefaultMultiProcessManagerImpl.addApplicationConfiguration("quickStartApplication", quickStartApp);

In the global configuration we chose configurationClassFileName. Now we add the new application file JLupinQuickStartApplicationConfigurationImpl.java to the same location: SERVER_HOME/start/configuration

The content of the configuration file of the application should look as follows:

package configuration;

import com.jlupin.impl.client.balancer.JLupinOutputParameterAnalyzerAlgSocketBalancerImpl;
import com.jlupin.impl.client.delegator.JLupinDefaultBalanceProxyDelegatorImpl;
import com.jlupin.impl.client.util.JLupinClientSocketConfiguration;
import com.jlupin.impl.container.application.JLupinSingleApplicationContainerForLocalProcessImpl;
import com.jlupin.impl.entrypoint.command.local.JLupinLocalCommandEntryPointImpl;
import com.jlupin.impl.entrypoint.defaults.JLupinDefaultEntryPointImpl;
import com.jlupin.impl.invoker.JLupinDefaultApplicationInvokerImpl;
import com.jlupin.impl.logger.impl.log4j.JLupinLoggerOverLog4jImpl;
import com.jlupin.impl.processor.JLupinDefaultServiceProcessorImpl;
import com.jlupin.impl.processor.inner.JLupinDefaultInnerServiceProcessorImpl;
import com.jlupin.impl.serialize.JLupinFSTSerializerImpl;
import com.jlupin.impl.server.JLupinDefaultBaseServerImpl;
import com.jlupin.interfaces.client.balancer.JLupinBalancer;
import com.jlupin.interfaces.client.delegator.JLupinDelegator;
import com.jlupin.interfaces.container.application.JLupinApplicationContainer;
import com.jlupin.interfaces.entrypoint.JLupinEntryPoint;
import com.jlupin.interfaces.invoker.application.JLupinApplicationInvoker;
import com.jlupin.interfaces.logger.JLupinLogger;
import com.jlupin.interfaces.processor.JLupinServiceProcessor;
import com.jlupin.interfaces.processor.inner.JLupinInnerServiceProcessor;
import com.jlupin.interfaces.serialize.JLupinSerializer;
import com.jlupin.interfaces.server.JLupinBaseServer;
import com.jlupin.interfaces.process.configuration.singleprocess.JLupinLocalSingleProcessConfiguration;
import java.net.InetSocketAddress;

public class JLupinQuickStartApplicationConfigurationImpl implements JLupinLocalSingleProcessConfiguration{

    public void before() {

    }

    public void after() {

    }

    public JLupinBaseServer getJLupinLocalBaseServer() {
        JLupinDefaultBaseServerImpl jLupinDefaultBaseServer = new JLupinDefaultBaseServerImpl("default");
        jLupinDefaultBaseServer.setThreadPoolSize(64);
        return jLupinDefaultBaseServer;
    }

    public JLupinBaseServer getJLupinLocalCommandServer() {
        JLupinDefaultBaseServerImpl jLupinDefaultBaseServer = new JLupinDefaultBaseServerImpl("command");
        jLupinDefaultBaseServer.setThreadPoolSize(4);
        jLupinDefaultBaseServer.setWaitForFinishExecuteAllRequests(false);
        return jLupinDefaultBaseServer;
    }

    public JLupinEntryPoint getJLupinLocalCommandEntryPoint() {
        return new JLupinLocalCommandEntryPointImpl();
    }

    public JLupinEntryPoint getJLupinLocalEntryPoint() {
        JLupinDefaultEntryPointImpl jLupinDefaultEntryPoint = new JLupinDefaultEntryPointImpl();
        return jLupinDefaultEntryPoint;
    }

    public  JLupinServiceProcessor getJLupinServiceProcessor() {
        JLupinServiceProcessor jLupinServiceProcessor = new JLupinDefaultServiceProcessorImpl();
        return jLupinServiceProcessor;
    }

    public JLupinInnerServiceProcessor getJLupinInnerServiceProcessor() {
        return new JLupinDefaultInnerServiceProcessorImpl();
    }

    public JLupinApplicationInvoker getJLupinApplicationInvoker() {

        JLupinClientSocketConfiguration clientSocketConfServer = new JLupinClientSocketConfiguration();
        clientSocketConfServer.setSocketAddressToConnectServer(new InetSocketAddress("localhost", 9090));
        clientSocketConfServer.setConnectionTimeout(30000);

        JLupinBalancer jLupinBalancer = new JLupinOutputParameterAnalyzerAlgSocketBalancerImpl(
                4, getJLupinLogger(), getJLupinSerializer(),clientSocketConfServer);

        JLupinDelegator jLupinBalanceDelegator = new JLupinDefaultBalanceProxyDelegatorImpl(jLupinBalancer);

        return new JLupinDefaultApplicationInvokerImpl(new JLupinDelegator[] {jLupinBalanceDelegator});
    }

    public JLupinApplicationContainer getJLupinApplicationContainer() {
        JLupinSingleApplicationContainerForLocalProcessImpl jLupinSingleApplicationContainerForLocalProcess =
                new JLupinSingleApplicationContainerForLocalProcessImpl(
                        new String[] {"classpath:spring-services.xml"});
        return jLupinSingleApplicationContainerForLocalProcess;
    }

    public JLupinLogger getJLupinLogger() {
        return JLupinLoggerOverLog4jImpl.getInstance();
    }

    public JLupinSerializer getJLupinSerializer() {
        return JLupinFSTSerializerImpl.getInstance();
    }
}

Step 5:
Application installation:

Create the quickStartApplication directory in the location: SERVER_HOME/application/

Compile and package project - execute command

mvn clean package

Upload the following file to the created application directory above:
- the application library - in this case: quick-start-1.3.0.jar.

This JAR includes:
- QuickStartService.class
- QuickStartServiceImpl.class
- spring-services.xml (defined in the JLupinQuickStartApplicationConfigurationImpl.java
conf file)
- log4j.xml

Content of the file log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<!-- ===================================================================== -->
<!--                                                                       -->
<!--  Log4j Configuration                                                  -->
<!--                                                                       -->
<!-- ===================================================================== -->

<!--
   | For more configuration information and examples see the Jakarta Log4j
   | owebsite: http://jakarta.apache.org/log4j
 -->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

   <!-- ================================= -->
   <!-- Preserve messages in a local file -->
   <!-- ================================= -->

   <!-- A time/startCommandExecuteDate based rolling appender -->
   <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="File" value="../logs/server/local/quickStartApplication/run/sample.log"/>
      <param name="Append" value="true"/>

      <!-- Rollover at the top of each hour -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>

      <!--param name="MaxFileSize" value="200MB"/-->
        <!-- Keep one backup file -->
      <!--param name="MaxBackupIndex" value="10"/-->

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] (Thread) Messagen -->
         <param name="ConversionPattern" value="%d %-5p [%c] (%t)  %m%n"/>

      </layout>
   </appender>

    <appender name="ASYNC_FILE" class="org.apache.log4j.AsyncAppender">
        <param name="BufferSize" value="1000"/>
        <appender-ref ref="FILE"/>
    </appender>

   <!-- ======================= -->
   <!-- Setup the Root category -->
   <!-- ======================= -->

   <root>
      <priority value="debug"/>
      <appender-ref ref="ASYNC_FILE"/>
   </root>

</log4j:configuration>

Step 6

server start-up

In catalogue SERVER_HOME/start

Start the file start.cmd or start.sh depending on the environment. After the server start-up you should see the following details (marked)

Step 7

Writing the calling JUNIT - test for the service "quickStartService":

package com.jlupin.test;

import com.jlupin.impl.client.delegator.JLupinSocketDelegatorImpl;
import com.jlupin.impl.client.proxy.producer.JLupinDefaultProxyObjectProducerImpl;
import com.jlupin.impl.logger.impl.simple.stdout.JLupinSimpleSystemOutLoggerImpl;
import com.jlupin.impl.serialize.JLupinFSTSerializerImpl;
import com.jlupin.interfaces.client.proxy.producer.JLupinProxyObjectProducer;
import com.jlupin.interfaces.common.to.JLupinInputParameter;
import com.jlupin.interfaces.logger.JLupinLogger;
import com.jlupin.interfaces.logger.enums.LogMode;
import com.jlupin.interfaces.serialize.JLupinSerializer;
import com.jlupin.quickstart.service.QuickStartService;
import java.net.InetSocketAddress;
import java.util.Locale;

public class QuickStartServiceTest {

    private JLupinLogger jLupinLogger;

    public QuickStartServiceTest() {

        JLupinSimpleSystemOutLoggerImpl.initializeWithLogMode(LogMode.DEBUG);
        jLupinLogger = JLupinSimpleSystemOutLoggerImpl.getInstance();
    }

    private JLupinProxyObjectProducer getObjectProducer() {
        JLupinSerializer jLupinSerializer = JLupinFSTSerializerImpl.getInstance();

        JLupinSocketDelegatorImpl jLupinDelegator = new JLupinSocketDelegatorImpl(jLupinLogger, jLupinSerializer);
        jLupinDelegator.setSocketAddressToConnectServer(new InetSocketAddress("localhost", 9090));
        jLupinDelegator.setReadTimeout(30000);

        return new JLupinDefaultProxyObjectProducerImpl("quickStartApplication", "testClientApplication",
                                                        jLupinDelegator, jLupinLogger);
    }

    private  QuickStartService produceQuickStartService() throws Exception {
        JLupinProxyObjectProducer jLupinProxyObjectProducer = getObjectProducer();

        JLupinInputParameter jLupinInputParameter = new JLupinInputParameter(
                             "quickStartService","sessionId", "requestId",
                             "139.0.1.3",new Locale("en"), "user_name",
                             new String[] {"privilege_1", "privilege_2"});

        return jLupinProxyObjectProducer.produceObject(QuickStartService.class, jLupinInputParameter);
    }

    @org.junit.Test
    public void test() throws Throwable {
        QuickStartService quickStartService = produceQuickStartService();
        int randomInt  = quickStartService.getRandomInt();
        jLupinLogger.info("received random int:" + randomInt);
    }

    public static void main(String[] args) throws Throwable {
        QuickStartServiceTest quickStartServiceTest = new QuickStartServiceTest();
        quickStartServiceTest.test();
    }
}

The test() method create the proxy object to an appropriate remote service available at the JLupin server.

The proxy object is created by the producer of JLupinDefaultProxyObjectProducerImpl which takes the following arguments in its constructor: the name of the application to refer to, the name of the application to refer from, an appropriate delegator (JLupinDelegator interface - more about delegators, see the full documentation - delegators) in this case it is JLupinSocketDelegatorImpl which can be used for direct communication with the one to one server or to configure the external load balancer - see Figure:

Using a different implementation of delegator JLupinDefaultBalanceProxyDelegatorImpl connected with the implementation of the JLupinBalancer interface (software balancers), the communication would look like as follows (more on balancers, see the full documentation section - load balancers).

The difference between delegators JLupinSocketDelegatorImpl (in the option with the external load balancers) and JLupinDefaultBalanceProxyDelegatorImpl is shown in the following diagram:

Let us go back to our example:

The producer of JLupinDefaultProxyObjectProducerImpl uses the JLupinInputParameter input parameters as the object to produce the remote object proxy. The object carries a wide range of input information (e.g. session number, request number, user name, IP number, service name under which the service object is configured on the server, user rights array, the Locale object that specifies the language).

JLupinInputParameter and its constructors are shown below:

public JLupinInputParameter(JLupinServiceDTO jLupinServiceDTO, String applicationName, String asynchronousBusName, String serviceName, String methodName, String sessionId, String requestId, Locale locale, String user, String[] privilegeNames)

public JLupinInputParameter(JLupinServiceDTO jLupinServiceDTO, String applicationName, String asynchronousBusName, String serviceName, String methodName, String sessionId, String requestId, String clientApplicationName, String ip, Locale locale, String user, String[] privilegeNames)

After downloading the proxy object

QuickStartService quickStartService = getServiceProxy(QuickStartService.class, "quickStartService");

we can operate directly in the object interface by calling its methods:

int randomInt  = quickStartService.getRandomInt();
jLupinLogger.info("received random int:" + randomInt);

Test result:

[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.command.JLupinDefaultCommandImpl MESSAGE ID:1 SESSION ID:sessionId REQUEST ID:requestId LEVEL:INFO THREAD:1 METHOD:execute LINE:80 LOG:START command process with request id:requestId, session id:sessionId, service name:quickStartService, method name:getRandomInt
[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.command.JLupinDefaultCommandImpl MESSAGE ID:12 SESSION ID:sessionId REQUEST ID:requestId LEVEL:DEBUG THREAD:1 METHOD:execute LINE:84 LOG:START command process with input parameters:JLupinInputParameter{jLupinServiceDTO=null', function args=null', applicationName='quickStartApplication', serviceName='quickStartService', methodName='getRandomInt', requestId='requestId', sessionId='sessionId', locale=pl, privilegeNames=[user_privilege_1, user_privilege_2], user='test', sequenceName='null', asynchronousBusName='null', clientApplicationName='testClientApplication', ip='192.168.11.109'}
[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.command.JLupinDefaultCommandImpl MESSAGE ID:13 SESSION ID:sessionId REQUEST ID:requestId LEVEL:DEBUG THREAD:1 METHOD:execute LINE:88 LOG:JLupinDelegator impl class:com.jlupin.impl.client.delegator.JLupinSocketDelegatorImpl
[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.delegator.JLupinSocketDelegatorImpl MESSAGE ID:1 SESSION ID:sessionId REQUEST ID:requestId LEVEL:DEBUG THREAD:1 METHOD:delegate LINE:58 LOG:delegate to service:quickStartService
[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.command.JLupinDefaultCommandImpl MESSAGE ID:15 SESSION ID:sessionId REQUEST ID:requestId LEVEL:INFO THREAD:1 METHOD:execute LINE:148 LOG:STOP command process - process time (milliseconds):97 with request id:requestId and session id:sessionId
[2015-10-01 10:31:28] CLASS:com.jlupin.impl.client.command.JLupinDefaultCommandImpl MESSAGE ID:16 SESSION ID:sessionId REQUEST ID:requestId LEVEL:DEBUG THREAD:1 METHOD:execute LINE:152 LOG:STOP command process - process time (milliseconds):97 with request id:requestId and session id:sessionId and output object:JLupinOutputParameter{jLupinExceptionModel=null, jLupinServiceDTO=null, executedServiceError=false, resultObject=-1735197954}
[2015-10-01 10:31:28] CLASS:com.jlupin.test.QuickStartServiceTest MESSAGE ID:0 LEVEL:INFO THREAD:1 METHOD:test LINE:61 LOG:received random int:-1735197954

At the end various way to invoke quickStartService by WEB SERVICE SOAP XML interface

Address: http://localhost:8082/jLupinNextServerWebService/JLupinWebservice

input:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ent="http://entrypoint.impl.jlupin.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <ent:jLupinService>
         <jLupinInputParameter>
         <applicationName>quickStartApplication</applicationName>
           <locale>pl</locale>
            <methodName>getRandomInt</methodName>
              <privilegeList>
               <privilegeName>privilege</privilegeName>
            </privilegeList>
            <requestId>request1</requestId>
            <sequenceName>sampleParamArrayXmlInOutSequence</sequenceName>
             <serviceName>quickStartService</serviceName>
            <sessionId>session1</sessionId>
            <user>test_user</user>
             <busName>busName</busName>
         </jLupinInputParameter>
     </ent:jLupinService>
   </soapenv:Body>
</soapenv:Envelope>

Output:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <jlns:jLupinServiceResponse xmlns:jlns="http://entrypoint.impl.jlupin.org/">
       <jLupinOutputParameter>
        <executedServiceError>false</executedServiceError>
        <result><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
         <java version="1.8.0_45" class="java.beans.XMLDecoder">
         <int>-1657464644</int>]]>
        </result>
       </jLupinOutputParameter>
      </jlns:jLupinServiceResponse>
   </env:Body>
</env:Envelope>

by WEB SERVICE HTTP-JSON interface (available from 1.2.0 server version):

Address: http://localhost:8083/jLupinNextServerRestService/JLupinRestservice

Input:

{
  "jLupinInputParameter": {
    "applicationName": "quickStartApplication",
    "locale": "pl",
    "methodName": "getRandomInt",
    "privilegeList": [ "privilege_1", "privilege_2" ],
    "requestId": "request_1",
    "serviceName": "quickStartService",
    "sequenceName":"sampleParamArrayJsonInOutSequence",
    "sessionId": "session_1",
    "user": "test_user",
  }
}

Output:

{"jLupinOutputParameter": {
   "result": "-1685768211",
   "executedServiceError": false
}}

Call through queue interface:

In this case we recommend execution of QuickStartServiceImpl class code in asynchronous mode – i.e. we recommend execution of certain code (getRandomInt method) for a given queue (asynchronous bus - simpleBus), we get the id of the task and the server processes class code execution by defining the queue. The diagram of queue call is shown in the picture below:

Note that the traffic goes to another port – 9093 in this case, and the result is the id of the task accepted to the queue. We don't use mechanisms JLupin Java Remote Invocation by direct using the class interface, but provide all input parametres in JLupinInputParameter object, we send it to the JLupinSocketDelegatorImpl object and get the JLupinOutputParameter obiect from which we get the task id.

Let's have look at this fragment:

JLupinInputParameter jLupinInputParameter = new JLupinInputParameter("quickStartService","sessionId", "requestId",
        ip,new Locale("pl"), userName, new String[] {"user_privilege_1", "user_privilege_2"});

jLupinInputParameter.setApplicationName("quickStartApplication");
jLupinInputParameter.setMethodName("getRandomInt");
jLupinInputParameter.setAsynchronousBusName("simpleBus");

by creating the JLupinInputParameter transport object we put the following information in the constructor:
- service name
- sesion id
- request id
- client ip address
- Locale variable that defines the client language
- username
- table of permissions

In further setters we provide:

  • application name the request should go to
  • method name
  • asynchronous bus name

Full call class code:

package com.jlupin.test;

import com.jlupin.impl.client.delegator.JLupinSocketDelegatorImpl;
import com.jlupin.impl.logger.impl.simple.stdout.JLupinSimpleSystemOutLoggerImpl;
import com.jlupin.impl.serialize.JLupinFSTSerializerImpl;
import com.jlupin.interfaces.common.to.JLupinInputParameter;
import com.jlupin.interfaces.common.to.JLupinOutputParameter;
import com.jlupin.interfaces.logger.JLupinLogger;
import com.jlupin.interfaces.logger.enums.LogMode;
import com.jlupin.interfaces.serialize.JLupinSerializer;
import org.junit.Before;
import java.net.InetSocketAddress;
import java.util.Locale;

public class QuickStartServiceAsynchronousTest {

    private JLupinLogger jLupinLogger;
    private JLupinSerializer jLupinSerializer;
    private JLupinSocketDelegatorImpl jLupinDelegator;

    @Before
    public void before() {
        JLupinSimpleSystemOutLoggerImpl.initializeWithLogMode(LogMode.DEBUG);
        jLupinLogger     = JLupinSimpleSystemOutLoggerImpl.getInstance();
        jLupinSerializer = JLupinFSTSerializerImpl.getInstance();
        jLupinDelegator = new JLupinSocketDelegatorImpl(jLupinLogger, jLupinSerializer);
        jLupinDelegator.setSocketAddressToConnectServer(new InetSocketAddress("localhost", 9093));
        jLupinDelegator.setConnectionTimeout(30000);
    }

    @org.junit.Test
    public void test() throws Throwable {
        String taskId = addAsynchronousTask();
        jLupinLogger.info("task id:" + taskId );
    }

    private String addAsynchronousTask() throws Throwable {

        JLupinInputParameter jLupinInputParameter = new JLupinInputParameter(
                                                    "quickStartService","sessionId", "requestId",
                                                    "139.0.1.3",new Locale("en"), "user_name",
                                                    new String[] {"privilege_1", "privilege_2"});

        jLupinInputParameter.setApplicationName("quickStartApplication");
        jLupinInputParameter.setMethodName("getRandomInt");
        jLupinInputParameter.setAsynchronousBusName("simpleBus");

        JLupinOutputParameter jLupinOutputParameter = jLupinDelegator.delegate(jLupinInputParameter);

        if(!jLupinOutputParameter.isExecutedServiceError()) {
            String taskId = jLupinOutputParameter.getResultObject();
            return taskId;
        }
        else
        {
            jLupinLogger.info("an unexpected error occurred during added task into asynchronous queue caused by:" +
                              jLupinOutputParameter.getJLupinExceptionModel());
            return null;
        }

    }

}

Call effect:

[2015-10-27 09:12:01] CLASS:com.jlupin.test.QuickStartServiceAsynchronousTest MESSAGE ID:0 LEVEL:INFO THREAD:1 METHOD:test LINE:37 LOG:task id: 35a65c8d364a6a35e6c5bc972e35fb244d6b1f92726fe254908e9ea6d8d10756)

Let's have a look at the server log.

To see the entry below on a server it is necessary to change login mode to debug. To enable this it is required to change the following entry in log4j.xml file in server-resources directory:

<priority value="DEBUG"/>

Logs:

Task acceptance to execute in queue:

2015-10-27 09:12:01,597 DEBUG [com.jlupin.impl.entrypoint.multiprocess.binary.asynchronous.bus.JLupinAsynchronousBus] (pool-29-thread-1)  MESSAGE ID:1 LINE:52 LOG:added task:JLupinAsynchronousTask{id='35a65c8d364a6a35e6c5bc972e35fb244d6b1f92726fe254908e9ea6d8d10756', inputTimeInMillis=1445933521597, probeCounter=0, applicationName='quickStartApplication', serviceName='quickStartService', busName='simpleBus', sessionId='sessionId', requestId='requestId', methodName='getRandomInt'} into bus:simpleBus
2015-10-27 09:12:01,751 INFO  [com.jlupin.impl.entrypoint.multiprocess.binary.asynchronous.multithreading.JLupinMultiThreadingBinaryAsynchronousEntryPointImpl] (pool-29-thread-1)  MESSAGE ID:42 LINE:114 LOG:successfully added task:JLupinAsynchronousTask{id='35a65c8d364a6a35e6c5bc972e35fb244d6b1f92726fe254908e9ea6d8d10756', inputTimeInMillis=1445933521597, probeCounter=0, applicationName='quickStartApplication', serviceName='quickStartService', busName='simpleBus', sessionId='sessionId', requestId='requestId', methodName='getRandomInt'} into task list

Task execution:

2015-10-27 09:12:03,766 DEBUG [com.jlupin.impl.entrypoint.multiprocess.binary.asynchronous.bus.JLupinAsynchronousBus] (pool-9-thread-19)  MESSAGE ID:33 LINE:114 LOG:executing task:JLupinAsynchronousTask{id='35a65c8d364a6a35e6c5bc972e35fb244d6b1f92726fe254908e9ea6d8d10756', inputTimeInMillis=1445933521597, probeCounter=0, applicationName='quickStartApplication', serviceName='quickStartService', busName='simpleBus', sessionId='sessionId', requestId='requestId', methodName='getRandomInt'}

Task execution confirmation:

2015-10-27 09:12:04,259 DEBUG [com.jlupin.impl.manager.multiprocess.JLupinDefaultNewMultiProcessManagerImpl] (pool-9-thread-19)  MESSAGE ID:2891 LINE:2085 LOG:task:35a65c8d364a6a35e6c5bc972e35fb244d6b1f92726fe254908e9ea6d8d10756 executed correctly