Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Integration with Hazelcast MapStore #11656

Closed
bhagathk opened this issue Oct 23, 2017 · 7 comments
Closed

Spring Integration with Hazelcast MapStore #11656

bhagathk opened this issue Oct 23, 2017 · 7 comments

Comments

@bhagathk
Copy link

@bhagathk bhagathk commented Oct 23, 2017

I am trying to integration Spring and Hazelcast with Mapstore Implementation. I am not able to autowire the JdbcTemplate in the Mapstore class.
1.) Is there a way I can actually autowire my repository in the MapStore Class?

public class DefaultNoSQLMapStore implements MapStore<String,Object>{
	@Autowired
	private JdbcTemplate jdbcTemplate;

Here, jdbcTemplate results a null value.

As a work around I am able to implement mapstore and use the jdbcTemplate using the
MapStoreLifeCycleSupport and init() method to load instantiate jdbcTemplate and use it in the MapStore.

Also I have seen an example where we add hazelcast as a bean in the spring configuration xml and get the jdbc template using applicationContext.getBean() method.
2.) If this is the only solution to actually Integrate Hazelcast Mapstore with Spring then
Is there a way to have Hazelcast.xml seperated from spring configuration xml and still achieve this?

@vbekiaris
Copy link
Contributor

@vbekiaris vbekiaris commented Oct 23, 2017

@bhagathk you should be able to get spring-managed beans injected in your MapStore implementation by annotating your implementation as @SpringAware. See documentation here and the sample code here

@mmedenjak mmedenjak added this to the 3.10 milestone Oct 23, 2017
@bhagathk
Copy link
Author

@bhagathk bhagathk commented Oct 23, 2017

@vbekiaris In this Documentation, the hazelcast is a bean in the spring configuration xml, It doesn't say anything about how I can make spring read the Hazelcast.xml. I want to have the hazelcast.xml seperate from the spring configuration and should be able to achieve this functinality as I explained above. Is it possible?

@bhagathk
Copy link
Author

@bhagathk bhagathk commented Oct 31, 2017

@vbekiaris Any Information related to my Above Question?

@mesutcelik
Copy link
Contributor

@mesutcelik mesutcelik commented Oct 31, 2017

Hi @bhagathk ,
It is actually inconvenient not to use spring configuration because it is an option we offer to keep all configuration in the same place.

If you want to use hazelcast.xml seperately, here are the options you can use in your application
http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#checking-configuration

@bhagathk
Copy link
Author

@bhagathk bhagathk commented Nov 1, 2017

Hi @mesutcelik,
I am actually looking to use two files Spring application-context.xml and Hazelcast.xml. Where the application-context.xml will be able to read the hazelcast.xml we have provided. So that Hazelcast will be part of the Spring Configuration.

@mesutcelik
Copy link
Contributor

@mesutcelik mesutcelik commented Nov 1, 2017

If you are using hazelcast.xml based on hazelcast-config.xsd then what you ask is not possible.

If it is based on hazelcast-spring.xsd then you just need to import it into applicationContext.xml as below.

<import resource="classpath:spring_xsd_based_hazelcast.xml" />

@bhagathk
Copy link
Author

@bhagathk bhagathk commented Dec 1, 2017

We are able resolve the issue by using Spring's ApplicationContextAware to get the Application Context. Using this Application Context we are getting the JBDC Template in the mapstore class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.