동일한 Tomcat에서 Java WAR 파일과 JRuby WAR 파일을 실행하는 하이브리드 웹 응용 프로그램이 있습니다.Java to JRuby to Resque
작업 큐로 (JRuby) Resque를 사용하기로 결정했습니다. 작업을 대기열에 대한 호출은 다음과 같습니다
FooWorker가 노동자 클래스합니다 (JRuby를 WAR 파일과 포함)에 정의 및 사용 JRuby를 측에서이고, 그것이 JRuby를 Resque 레이크 작업에 의해 호출Resque.enqueue(FooWorker, 111)
대기열에서 작업을 처리 할 때
JRuby FooWorker 클래스에서 처리 할 Resque 대기열에 작업을 대기열에 넣을 수있는 기능을 Java 코드에 제공하고 싶습니다.
나는 Tommy Cheng의 코드 https://github.com/tc/call-jruby-from-java-example을 살펴 보았습니다. 자바 파일
//JavaInterfaceExample.java
interface JavaInterfaceExample{
int add(int a, int b);
}
과 루비 파일
#JrubyAdderImpl.rb
require 'java'
class JrubyAdderImpl
include Java::JavaInterfaceExample
java_signature 'int add(int, int)'
def add(a, b)
a+b
end
end
내 코드의 모습 의심 : 자바 파일
//ResqueInterfaceExample.java
interface ResqueInterfaceExample{
int resque_enqueue_foojob(int a);
}
루비 파일
#JrubyResqueImpl.rb
require 'java'
require 'resque'
class JrubyResqueImpl
include Java::ResqueInterfaceExample
java_signature 'int resque_enqueue_foojob(int)'
def resque_enqueue_foojob(a)
Resque.enqueue(FooWorker, a)
end
end
My FooWorker는 레일즈 애플리케이션의 전개 된 war 파일 디렉토리에있는 클래스이며 파일은 app/workers/foo_worker.rb입니다.
jruby 컴파일러가 두 가지 모두에 액세스 할 수 있도록하려면 어떻게해야합니까? FooWorker 및 Resque JRuby 클래스를 사용하여 코드를 올바르게 컴파일 할 수 있습니까?
우수! 제스케를 지적 해 주셔서 감사합니다. –