Java에서 프로세스 간 통신 라이브러리를 찾고 있습니다. JVM간에 작은 메시지를 보내려하고 있으며 가능한 경우 공유 메모리를 사용하여이를 수행하려고합니다.inter jvm communication
답변
Terracotta을 살펴 보시기 바랍니다. 테라코타의 주요 목표는 완벽한 확장 성 ("api"는 메모리 액세스)이지만 사용자 정의 요구 사항에 맞는지 여부는 알 수 없지만 메시징 통합 모듈은 분명히 있습니다. opensource입니다.
건배.
Java NIO는 메모리 맵 파일을 지원합니다. 여러 JVM이 동일한 파일을 메모리 맵핑하면 공유 메모리로 사용할 수 있습니다.
다음은 파일을 메모리 매핑하는 예제입니다.
try {
int shmSize = 1024;
RandomAccessFile file = new RandomAccessFile("shm.raw","rw");
// inialize file size
if(file.length() < shmSize) {
byte[] tmp = new byte[shmSize];
file.write(tmp);
file.seek(0); // seek back to start of file.
}
// memory-map file.
FileChannel ch = file.getChannel();
MappedByteBuffer shm = ch.map(FileChannel.MapMode.READ_WRITE, 0, shmSize);
ch.close(); // channel not needed anymore.
shm.load(); // force file into physical memory.
// now use the ByteBuffer's get/put/position methods to read/write the shared memory
} catch(Exception e) { e.printStackTrace(); }
Linux의 경우/dev/shm/메모리 기반 파일 시스템에서 shm.raw 파일을 만들 수 있습니다. 이렇게하면 디스크 I/O를 피할 수 있습니다. 자세한 내용은
또한 여전히 읽기/공유 메모리에 기록 syncronize 수있는 방법이 필요합니다이 문서 Introduction to Memory-Mapped IO in Java
을 읽어 보시기 바랍니다. 송신자 JVM은 완전한 메시지가 기록 될 때 수신자 JVM에 신호를 보내야합니다.
Java 사용 NIO의 SocketChannel은 메시지 수신시 수신자에게 알릴 수 있기 때문에 작은 메시지의 경우 더 나을 수 있습니다. 공유 메모리는 큰 메시지를 보낼 때만 도움이됩니다. 다른 컴퓨터에서의 JVM 사이의 IPC를 들어
내가 테라코타 보았다 JIPCinter-machine의 경우 통신에서 JGroups 또는 Sockets를 사용하고 intra-JVM에서는 Queue가 작동합니다. 통신 구성 요소의 구멍은 동일한 기계에서 프로세스 간입니다. – Javamann
- 1. Javascript to flash communication
- 2. Frontend Intertag Communication
- 3. C# Delphi ComPort Communication
- 4. WindowsPresentationFoundation 대 Windows Communication Foundation
- 5. Fogbugz and ELMAH - Communication Plugin
- 6. Windows Communication Foundation 간단한 시작
- 7. android to leopard board communication
- 8. 클러스터링 JVM
- 9. Java/C# Kerberos inter-op 가능합니까?
- 10. Java Inter Application Form 통신 옵저버 패턴
- 11. CQRS + DDD + 이벤트 소싱의 Inter-Aggregate 통신
- 12. Excel inter-op 파일 이름 바꾸기
- 13. Windows Communication Foundation 서비스 라이브러리 프로젝트
- 14. NFC (Near-Field Communication) 가능 전화 목록
- 15. 읽기 - 쓰기 pipe() communication in R
- 16. j2se to j2me WTK bluetoooth communication
- 17. Communication Gap : User vs Analyst-Designer
- 18. 두 개의 서로 다른 JVM에서 실행되는 두 응용 프로그램이 서로 상호 작용하는 방법은 무엇입니까?
- 19. JVM 1.6.0_23에서 JVM/핫 스폿 가비지 콜렉션을 디버그하기위한 소스 얻기
- 20. jvm 디자인 결정
- 21. JVM 사양 업데이트
- 22. OS로 메모리를 보내는 JVM
- 23. jvm 충돌 로그 피하기
- 24. JVM 스택 인트로 피킹
- 25. tomcat jvm options
- 26. Amazon EC2에서 JVM 튜닝
- 27. jvm warmup 피하기
- 28. JVM 메모리 기본값
- 29. 질문이 KVM (JVM)
- 30. JVM 용 C++ 컴파일
을 시도하지만이 문제에 대한 매우 무거운 솔루션입니다. Thx – Javamann