I am developing an application managed by amazon simple workflow and spring 4 with annotation based dependency injection.
IMyActivity.java
package com.test.activities;
import com.amazonaws.services.simpleworkflow.flow.annotations.Activities;
import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions;
@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 3000,
defaultTaskStartToCloseTimeoutSeconds = 100)
@Activities(version="1.0")
public interface IMyActivity {
String dofunc();
}
MyActivityImpl.java
package com.test.activities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.test.services.TransactionService;
@Component
public class MyActivityImpl implements IMyActivity {
@Autowired
private ITransactionService transactionService;
@Override
public String dofunc() {
return transactionService.dosomething();
}
}
The problem I am facing is that when the activity is scheduled by swf,ITransactionService
implementation is not getting injected and transactionService
is null. However, everything works fine when the IMyActivity myactivity
is @Autowired
from anywhere else and is not called by swf.
Am I doing something wrong here? Please help.
I followed this documentation http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/test.html#test.spring. This is the official amazon swf documentation for its integration using spring. Worked like a charm.