Kestrel use Java to exploit

Source: Internet
Author: User

Kestrel is used Scala,java cannot be used directly. If you want to run Kestrel in Java, you need to use the xmemcached library.   Create queue_kestrel.java# cd# mkdir test# export source_dir=~/test# vi queue_kestrel.java -------------------- ---------------------------------Import Net.rubyeye.xmemcached.memcachedclient;import Net.rubyeye.xmemcached.xmemcachedclientbuilder;import net.rubyeye.xmemcached.command.KestrelCommandFactory; Import Net.rubyeye.xmemcached.utils.addrutil; public class Queue_kestrel {public static void main (string[] args) Throws Exception {Xmemcachedclientbuilder builder=null; Memcachedclient Client=null;int expirationtime=0; String queuename= "Test"; String host= "192.168.172.99"; String port = "22133"; builder=new xmemcachedclientbuilder (Addrutil.getaddresses (host+ ":" +port)); Builder.setcommandfactory (New Kestrelcommandfactory ()); try {client=builder.build (); Client.set (QueueName, Expirationtime, "Hello"); String Res=client.get (queuename); System.out.println (res);} catch (Java.io.IOException e) {}}}----------------------------------------------------  Prepare the necessary libraries. xmemcached# wget http://xmemcached.googlecode.com/files/xmemcached-1.3.7-bin-with-dependencies.tar.gz# Tar zxvf xmemcached-1.3.7-bin-with-dependencies.tar.gz# CP Xmemcached-1.3.7/xmemcached-1.3.7.jar xmemcached-1.3.7/lib/ Slf4j-api-1.5.7.jar $source _dir slf4j# wget http://www.slf4j.org/dist/slf4j-1.6.6.zip# Unzip slf4j-1.6.6.zip# CP Slf4j-1.6.6/slf4j-jdk14-1.6.6.jar $source _dir kestrel# Cp/usr/local/kestrel/kestrel_2.9.1-2.2.0.jar $ source_dir  run Start Kestrel server. # Java-jar/usr/local/kestrel/kestrel_2.9.1-2.2.0.jar &  compile Queue_kestrel.java and run. # CD $source _dir# JAVAC-CP./xmemcached-1.3.7.jar:./slf4j-api-1.5.7.jar:./slf4j-jdk14-1.6.6.jar:./kestrel_ 2.9.1-2.2.0.jar:queue_kestrel.java# JAVA-CP./xmemcached-1.3.7.jar:./slf4j-api-1.5.7.jar:./slf4j-jdk14-1.6.6.jar :./kestrel_2.9.1-2.2.0.jar:queue_kestrel

Kestrel in Java to take advantage of

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.