Saturday, 2 December 2017

HOW TO MAKE SKYPE CALL USING JAVA


The Desktop API (previously known as the Skype Public API – Application Programming Interface) enables third-party applications to communicate with Skype.

The Skype API provides a mechanism for 3rd party scripts and applications to control Skype UI functions and implement additional or improved features to complement the Skype. Skype is the world's fastest-growing Internet communication offering, allowing unlimited free voice, video and instant messaging communication between users of Skype Software. The API has two layers: The Communication Layer is a set of methods for external application to establish connection to Skype client and communicate with it, The Command Protocol Layer is a text-based "language" that external applications can use to speak to the Skype client, once communication channel is established by Communication Layer.


Kindly find the below code for integration skype using java.



package skypeapi;

/**
 *
 * @author aravindkumar.k
 */
import com.skype.ContactList;
import com.skype.Friend;
import com.skype.Skype;
import com.skype.SkypeException;
public class CallSkype {
    public static void main(String args[]){
        try{
           //Code to make Call using Skype
   Skype.call("skypeUserName");
   
   //Code to send the message using Skype
           Friend fr= list.getFriend("friend Name");
   fr.send("Good evening ");
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
    

}

To download the skype API kindly click on the link below

Skype API(Aravind)




Tuesday, 9 May 2017

Oracle Advanced Queuing

What Is Advanced Queuing?


When Web-based business applications communicate with each other, producer applications enqueue messages and consumer applications dequeue messages. Advanced Queuing provides database-integrated message queuing functionality. Advanced Queuing leverages the functions of the Oracle database so that messages can be stored persistently, propagated between queues on different machines and databases, and transmitted using Oracle Net Services, HTTP(S), and SMTP.

Since Oracle Advanced Queuing is implemented in database tables, all the operational benefits of high availability, scalability, and reliability are applicable to queue data. Standard database features such as recovery, restart, and security are supported in Advanced Queuing, and queue tables can be imported and exported.


Advanced Queuing in Integrated Application Environments

Advanced Queuing provides the message management functionality and asynchronous communication needed for application integration. In an integrated environment, messages travel between the Oracle database server and the applications and users.

Using Oracle Net Services, messages are exchanged between a client and the Oracle database server or between two Oracle databases. Oracle Net Services also propagates messages from one Oracle queue to another.

You can perform Advanced Queuing operations over the Internet using transport protocols such as HTTP, HTTPS, or SMTP. 


Interfaces to Advanced Queuing

You can access Advanced Queuing functionality through the following interfaces:
  • PL/SQL using DBMS_AQDBMS_AQADM, and DBMS_AQELM.
  • Visual Basic using Oracle Objects for OLE. Refer to the Online Help for Oracle Objects for OLE.
  • Java using the oracle.AQ Java package. 
  • Java Message Service (JMS) using the oracle.jms Java package.
  • Internet access using HTTP, HTTPS, and SMTP.

SQL Script to create the AQ table & Message Type


CREATE USER aq_user IDENTIFIED BY aq_user
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;


ALTER USER aq_user QUOTA UNLIMITED ON users;


EXECUTE dbms_aqadm.grant_type_access ('aq_user');

CREATE TYPE message_type AS OBJECT (message_id NUMBER (15),subject VARCHAR2(100),text VARCHAR2(100),dollarvalue NUMBER(4,2));


BEGIN
   -- ----------------------------------------------------

    DBMS_AQADM.CREATE_QUEUE_TABLE (
        queue_table        => 'aq_user.msg_qt'
      , queue_payload_type => 'aq_user.message_type'
    );

    -- ----------------------------------------------------

    DBMS_AQADM.CREATE_QUEUE (
        queue_name          => 'msg_queue'
      , queue_table         => 'aq_user.msg_qt'
      , queue_type          => DBMS_AQADM.NORMAL_QUEUE
      , max_retries         => 0
      , retry_delay         => 0
      , retention_time      => 1209600
      , dependency_tracking => FALSE
      , comment             => 'Test Object Type Queue'
      , auto_commit         => FALSE
    );
    -- ----------------------------------------------------

    DBMS_AQADM.START_QUEUE ('msg_queue');

    -- ----------------------------------------------------
END;



SQL Script to stop and drop the Queue

EXECUTE dbms_aqadm.stop_queue (queue_name => 'aq_user.msg_queue');
EXECUTE dbms_aqadm.drop_queue (queue_name => 'aq_user.msg_queue');
EXECUTE
dbms_aqadm.drop_queue_table (queue_table => 'aq_user.msg_qt');
 
DROP TYPE aq_user.message_type;
 


Configuring AQ adapter in Weblogic Console

1.Create a generic JDBC data source for the user you have created previously.

2.Create a outbound connection pool eis/aq/myQueue in AQ adapter.

Once it is done we can start creating the application using AQ adapter in SOA.


How to Create SOA Application Using AQ Adapter

You can refer to the below link to create an SOA application to perform the Enqueue operation in AQ adapter.


http://askmesoa.blogspot.in/2012/09/working-with-aq-adapter-in-soa.html


Incase if there has been any doubt in creating SOA application with AQ adapter.You can post your doubts in the comments sections.







Thursday, 4 May 2017

JMS

JMS (Java Message Service) is an API that provides the facility to create, send and read messages. It provides loosely coupled, reliable and asynchronous communication.

JMS is also known as a messaging service.

Requirement of JMS

Generally, user sends message to application. But, if we want to send message from one application to another, we need to use JMS API.

Consider a scenario, one application A is running in INDIA and another application B is running in USA. To send message from A application to B, we need to use JMS.

Messaging Domains

There are two types of messaging domains in JMS.

1)Point-to-Point Messaging Domain

2)Publisher/Subscriber Messaging Domain

1) Point-to-Point (PTP) Messaging Domain

In PTP model, one message is delivered to one receiver only. Here, Queue is used as a message oriented middleware (MOM).

The Queue is responsible to hold the message until receiver is ready.

In PTP model, there is no timing dependency between sender and receiver.



2) Publisher/Subscriber (Pub/Sub) Messaging Domain

In Pub/Sub model, one message is delivered to all the subscribers. It is like broadcasting. Here, Topic is used as a message oriented middleware that is responsible to hold and deliver messages.

In PTP model, there is timing dependency between publisher and subscriber.

JMS Programming Model
























How to use the JMS Adapter in SOA 12c



Oracle JCA Adapter for JMS (Oracle JMS Adapter), which enables an Oracle BPEL process or an Oracle Mediator component to interact with Java Messaging Service.

Configuring JMS Resources for JMSAdapter in Oracle SOA



Before building the applications using JMS adapter we have to configure the JMS rescouces for the JMS adapter in the weblogic console.

You can refer the below link to get the steo by step process to configure the JMS adapter

http://www.soatutor.com/2013/07/configuring-jms-resources-for-jmsadapter.html

How to build the application using JMS adapter in Oracle SOA



You can refer the below link to build a sample application using JMS adapter to consume and produce a message

http://learn-oraclesoa.blogspot.in/2013/04/oracle-jms-adapter-tutorial.html



If you have any doubt in configuration or builiding the application you can ask your doubt in the comments section.




Tuesday, 4 April 2017

How to fetch or download the Files from SFTP using Java



WHAT IS SFTP?


FTP, or "File Transfer Protocol" is a popular method of transferring files between two remote systems.
SFTP, which stands for SSH File Transfer Protocol, or Secure File Transfer Protocol, is a separate protocol packaged with SSH that works in a similar way over a secure connection. The advantage is the ability to leverage a secure connection to transfer files and traverse the filesystem on both the local and remote system.
In almost all cases, SFTP is preferable to FTP because of its underlying security features and ability to piggy-back on an SSH connection. FTP is an insecure protocol that should only be used in limited cases or on networks you trust.
Although SFTP is integrated into many graphical tools, this guide will demonstrate how to use it through its interactive command line interface.
In this post we are going to see how to fetch files from SFTP using Java.
Java Code to fetch Files from SFTP:
           JSch jsch = new JSch();
           String remoteFilePath = "uo1/test";
            jsch.setKnownHosts(remoteFilePath);
           Session session = jsch.getSession("sftpUserName", "localhost");
            session.setPassword("sftpPassWord");
            java.util.Properties config = new java.util.Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect();

            Channel channel = session.openChannel("sftp");
            channel.connect();
           ChannelSftp sftpChannel = (ChannelSftp) channel;
            Vector<ChannelSftp.LsEntry> list = sftpChannel.ls(remoteFilePath)
             int count = 0;
             sftpChannel.cd(remoteFilePath);
            for (ChannelSftp.LsEntry entry : list) {
             if (!entry.getAttrs().isDir()) {
                    sftpChannel.get(entry.getFilename(), entry.getFilename());
                    count++;
                }
                System.out.println(entry.getFilename());
            }
             System.out.println();
            System.out.println(count + " files downloaded.");
           sftpChannel.exit();
            session.disconnect();



Saturday, 11 February 2017

FILE ADAPTER IN SOA

  Oracle BPEL PM and Mediator include the Oracle File and FTP Adapters. The Oracle File and FTP Adapters enable a BPEL process or a Mediator to exchange (read and write) files on local file systems and remote file systems (through use of the file transfer protocol (FTP)). The file contents can be both XML and non-XML data formats.

There are mainly 4 operations in FILE adpater namely:
  • READ: its an inboun operation that reads a file from given dir path
  • WRITE: outbound operation to write files to a location specified under directory path
  • SYNCHRONUS READ: outbound operation used to read a file in middle of the process
  • LIST FILE: outbound operation to list all the files in a given directory

How to use the FILE adapter in SOA 12c


Let us seen in detail about the steps in File Polling using FILE Adapter in SOA 12c.

1.Create SOA Project Named "FilePolling"


2.Drag and drop file adpater from component pallette to exposed services lane.





3.File adapter configuration window will pop up.Give the service name as "filePollService" and click next.



4.Leave adapter interface default and move next.

If the you have wsdl which will meets our requirement, then we can select using “Import an existing wsdl” else we need to select the “Define from operation and schema”




4.Give the JNDI name for the file Adapter.



5.Since we are reading for new records in a file.Choose operation type as "Read" and click next.Other setting leave as it is.


6.Enter directory path from where file adapter will poll for new files.If you want to delete files after successful read, check "Deletd files after successful retreival".Also, provide the location for archiving the file as well and move next.






7. Now in this part we will provide the name of the files that we want to read. I have given as "test*.*" which means it will read all the files starting with test.Leave other settings default and click next.





8.In this window we define polling frequency which means after how many seconds or minutes our file adapter will poll for new files.Also, if you want your file adapter not to read all the files as they are written on the server, use the minimum file age option.Click next.




9.We will be writing the file as it is read, so choose opaque schema option.



10.Click next and finish.




11.Drag and drop another file adapter this time to external references lane for writing file purposes.File configuration wizard will open up.




12.Give the Service name as "WriteFile".



13.Leave the adapter interface as default and choose next.






14.Give the JNDI name for the file adapter.





15.Click next again and choose operation name as "Write File" and click next.





16.Specify the directory path where you want your files to be written and file naming convention to be used for files written.If you want that each record is being written to existing file only use "Append to existing File" option. Otherwise leave it default and click next.







17.Select Opaque Schema and click next.Click Finish









18.Drag and drop the BPEL process onto  the components lane.





19.Choose BPEL process as define interface later and give "FileBPELProcess" name to your BPEL process.





20.Wire both file adapters to the BPEL





21.Double click the BPEL process and open up BPEL designer.In the BPEL designer drag and drop one Receive activity and wire it to the "readFile" partner link.





22.Window will pop up for configuring receive activity.As done in JMS adpater tutorial check mark "Create Instance" and create input variable by clicking on "+" icon.






23.Drag and drop invoke activity below receive activity and wire it to the "WriteFile" partner link.




24. Invoke window will pop up.In the same manner like we did for receive activity create input variable for invoke activity.





25.Drag and drop the assing activity between recieve and invoke activity.






26.Double click the assing activity and map receive activity input variable to invoke activity input variable means same contents are being copied to output.





27.Now you can deploy and test the process.